Java Thread States
A thread in Java at any point of time exists in any one of the 6 states. This article give a quick introduction of different Thread states and respective methods which results in threads state change.
Following are the states of a Java Thread
- New: Thre thread is just created by using start() method on the tread
- Runnable: Thread state for a runnable thread. A thread in the runnable state is executing in the Java virtual machine but it may be waiting for other resources from the operating system such as a processor.
- Blocked: A thread in the blocked state is waiting for a monitor lock
- Waiting: A thread is in the waiting state due to calling one of the following methods:
Object.wait() with no timeout
Thread.join() with no timeout
LockSupport.park - Timed Waiting: A thread is in the timed waiting state due to calling one of the following methods with a specified positive waiting time:Thread.sleep (long)
Object.wait (long)
Thread.join (long)
LockSupport.parkNanos
LockSupport.parkUntil - Terminated: The thread has completed execution
No comments :
Post a Comment
Please leave your message queries or suggetions.
Note: Only a member of this blog may post a comment.