What are the various thread states in Java?

Answered

What are the various thread states in Java?

Ninja Asked on 18th September 2018 in Java.
Add Comment
1 Answer(s)
Best answer

A thread in Java can be in one of the following states:

  1. NEW: A thread that has not yet started is in this state.
  2. RUNNABLE: A thread executing in the Java virtual machine is in this state.
  3. BLOCKED: A thread that is blocked waiting for a monitor lock is in this state.
  4. WAITING: A thread that is waiting indefinitely for another thread to perform a particular action is in this state.
  5. 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.
  6. TERMINATED: A thread that has exited is in this state.

A thread can be in only one state at a given point in time. These states are virtual machine states which do not reflect any operating system thread states.

Ninja Answered on 18th September 2018.
Add Comment