Obtaining A Thread's State
A Thread can exist in a number of different states. you can obtain the current state of a thread by calling the getState() method defined by Thread. It is shown here:
It returns a value of type Thread.State that indicates the state of the thread at the time at which the call was made. State is an enumeration defined by Thread.
Here are the values the can be returned by getState().
Figure: Diagrams how the various thread states relate.
It returns a value of type Thread.State that indicates the state of the thread at the time at which the call was made. State is an enumeration defined by Thread.
Here are the values the can be returned by getState().
Value | State |
BLOCKED | A Thread that has suspended execution because it is waiting to acquire a look. |
NEW | A Thread that has not begun execution. |
RUNNABLE | A Thread that either is currently executing or will execute when it gains access to the CPU. |
TERMINATED | A Thread that has completed execution. |
TIMED_WAITING | A Thread that hsa suspended execution for a specified period of time, such as when it has called sleep(). This state is also entered when a timeout version of wait() or join() is called. |
WAITING | A Thread that has suspended execution because it is waiting for some action to occur. for example, it is waiting because of a call to a non-timeout version of wait() or join(). |
Figure: Diagrams how the various thread states relate.
Subscribe to:
Post Comments
(
Atom
)
No comments :
Post a Comment
Please Write a Message for Programming or something Related issues.