Candibiotic
News Update :

Transitioning Between Thread States, Thread States

Friday, August 21, 2009

Once a new thread is started, it will always enter the runnable state.
The thread scheduler can move a thread back and forth between the runnable state and the running state.
For a typical single-processor machine, only one thread can be running at a time, although many threads may be in the runnable state.
There is no guarantee that the order in which threads were started determines the order in which they'll run.
There's no guarantee that threads will take turns in any fair way. It's up to the thread scheduler, as determined by the particular virtual machine implementation. If you want a guarantee that your threads will take turns regardless of the underlying JVM, you can use the sleep() method. This prevents one thread from hogging the running process while another thread starves. (In most cases, though, yield() works well enough to encourage
your threads to play together nicely.)
A running thread may enter a blocked/waiting state by a wait(), sleep(), or join() call.
A running thread may enter a blocked/waiting state because it can't acquire the lock for a synchronized block of code.
When the sleep or wait is over, or an object's lock becomes available, thethread can only reenter the runnable state. It will go directly from waiting to running (well, for all practical purposes anyway).
A dead thread cannot be started again
Share this Article on :

0 comments:

Post a Comment

 

© Copyright Vinayak Wins 2010 -2011 | Design by Herdiansyah Hamzah | Published by Borneo Templates | Powered by Blogger.com.