Well till today i was under the impression that Threads have a state called "Running". A
thread is in "Running" state when its being currently executed by the JVM.
In case if the currently executing thread invokes yield() or if some high priority thread comes in the current thread moves to a state called "Runnable" and waits for its turn from the scheduler.
This is what the explanation is there in most of the books.
I saw the Thread API which has Thread.State:
The states are
BLOCKED
Thread state for a thread blocked waiting for a monitor lock.
NEW
A thread that has not yet started is in this state.
RUNNABLE
A thread executing in the Java virtual machine is in this state.
BLOCKED
A thread that is blocked waiting for a monitor lock is in this state.
WAITING
A thread that is waiting indefinitely for another thread to perform a particular action is in this state.
TIMED_WAITING
A thread that is waiting for another thread to perform an action for up to a specified waiting time is in this state.
TERMINATED
A thread that has exited is in this state
1) There is no state like "Running"
2) Have a look at the explanation of "Runnable":A thread executing in the
Java virtual machine is in this state.
Furher the code, proves the very same:
Result:
Thread Name:WorkerThread
I am run method
WorkerThread state is:RUNNABLE
a) This shows there is no state called "Running".
b) Is there a state called "xxxx" which is like " am waiting for my turn for the scheduler" like the so-called "Runnable" state described in books.
[ December 08, 2008: Message edited by: Deepak Jain ]