Starting a thread via html

Okay, to make it simple I'm gonna analogize everything...

Suppose we have a bag of marbles, each marble has a number on it, it can be any integer, and the bag will always be missing some numbers.

The program will have 3 states (In the Bag, Above the Bag, Below the Bag)

I have an applet that will handle what happens when they are in the states, the user handles what happens to the marbles by a link outside of the applet.

Now my question: If what happens to each marble is controlled by a thread, how do I execute the command to it, so far my application successfully receives the commands from the browser when the user clicks the link...

Should I use a global variable? Then if it matches the integer perform the duty, seems like I would need another thread? as well as an infinite loop. And if it is an infinite loop I would have to put thread.sleep on it, that would keep the cpu low... right? Also if I do that, what are the odds that my application would miss the execute command because it happens while the user clicks two links within a thread sleep timeout.

Any ideas would be appreciated, what would you do?

[1166 byte] By [DJHotIcea] at [2007-11-27 3:43:54]
# 1
Hi,Google for a thread tutorial and read about how you can use wait and notify. The threads that are waiting for commands should issue wait on a lock, and the click performed by a user should call notify or notifyAll.Kaj
kajbja at 2007-7-12 8:47:31 > top of Java-index,Java Essentials,New To Java...