Could someone tell me which of these methods directly stop a thread: wait() start() called on a new thread sleep() notify() yield()
posted 14 years ago
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()