aspose file tools*
The moose likes Threads and Synchronization and the fly likes directly stopping a thread Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Threads and Synchronization
Bookmark "directly stopping a thread" Watch "directly stopping a thread" New topic
Author

directly stopping a thread

Nigel Patching
Greenhorn

Joined: Jun 15, 2001
Posts: 7
Could someone tell me which of these methods directly stop a thread:
wait()
start() called on a new thread
sleep()
notify()
yield()
Ryan Langley
Ranch Hand

Joined: May 10, 2001
Posts: 46
wait() (within a synchronized code block of course) will cause the thread to stop until it is interrupted.
start() (used with a Thread based object) will in effect branch a new thread off from the currently executing thread. Both threads will run (theoretically) in parallel.
sleep() will make the currently running thread stop executing for a specified period of time, and then continue.
notify() will interrupt a thread that has called wait().
yield() will cause a thread to suspend operation so that other threads of equal or higher priority will be allowed to run by the thread scheduler, which could be the same thread that called the yield() method. This is usually used if a thread is carrying out a complex computation so that other threads can have a chance to run.
Originally posted by Nigel Patching:
Could someone tell me which of these methods directly stop a thread:
wait()
start() called on a new thread
sleep()
notify()
yield()


------------------
Cheers,
RL


Cheers,<P>RL
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: directly stopping a thread