Thread problems

how can I make my Thread waite for a unlimited amount of time?I dont think suspend and resume is the right choice?I want my thread to activate / deactivate when some button is pushed.. please help,thanks, esben
[245 byte] By [tomasTyva] at [2007-10-3 2:12:43]
# 1

YOu can't really "stop" a thread, you can just run it with idle speed...

So you have to check regularly for an event. If it doesn' come, just wait some more:

while(!goOn()){

sleep(1000);

}

// Okay, end of pause, now do something important!

Of course, you have to set some flag which is accessed synchronized.

Mongera at 2007-7-14 19:11:38 > top of Java-index,Java Essentials,New To Java...
# 2
Don't [url= http://forum.java.sun.com/thread.jspa?threadID=758379&messageID=4331390#4331390]crosspost!![/url]
bckrispia at 2007-7-14 19:11:38 > top of Java-index,Java Essentials,New To Java...