A thread state. A thread can is in one of the following states:
NEW
A thread that has not yet started are in this state.
RUNNABLE
A thread executing in the Java virtual machine was in this state.
BLOCKED
A thread that's blocked waiting for a monitor lock are in this state.
WAITING
A thread that's waiting indefinitely for another the thread to perform a particular action was in the this state.
TIMED_WAITING
A thread that's waiting for another the thread to perform an action for up to a specified waiting time was in this state.
TERMINATED
A thread that has exited is in the this state.
A thread can is in the only one state at a given point in time. These states is virtual machine States which don't reflect any operating system thread states.
- Waiting
public static final Thread.state waiting
Thread state for a waiting thread. A thread is in the waiting state due to calling one of the following methods:
Object.waitWith no timeout
Thread.joinWith no timeout
LockSupport.park
A thread in the waiting state was waiting for another thread to perform a particular action. For example, a thread of that have called object.wait () on an Object was waiting for another thread to call Object . Notify () or object.notifyall () on the that Object. A thread that have calledThread.Join () is waiting for a specified the thread to terminate.
- Park
public static void Park ()
Disables the current thread to thread scheduling purposes unless the permit is available.
If the permit is available then it's consumed and the call returns immediately; Otherwise the current thread becomes disabled for thread scheduling purposes and lies dormant until one of three things ha Ppens:
- Some other thread invokes with the current thread as the
unpark target;
- Some other thread interrupts the current thread; Or
- The call spuriously (that's, for no reason) returns.
This method does the which of these caused the method to return. Callers should re-check the conditions which caused the thread to park in the first place. Callers may also determine, for example, the interrupt status of the thread upon return.
- Parknanos
public static void Parknanos (Long Nanos)
Disables the current thread for thread scheduling purposes, for the specified waiting time, unless the permit is AVA Ilable.
If the permit is available then it's consumed and the call returns immediately; Otherwise the current thread becomes disabled for thread scheduling purposes and lies dormant until one of four things hap Pens
- Some other thread invokes with the current thread as the
unpark target;
- Some other thread interrupts the current thread; Or
- The specified waiting time elapses; Or
- The call spuriously (that's, for no reason) returns.
This method does the which of these caused the method to return. Callers should re-check the conditions which caused the thread to park in the first place. Callers may also determine, for example, the interrupt status of the thread, or the elapsed time upon return.
-
Parameters:
-
nanos -The maximum
number of nanoseconds to wait
- Parkuntil
public static void Parkuntil (long deadline)
Disables the current thread for thread scheduling purposes, until the specified deadline, unless the permit is available.
If the permit is available then it's consumed and the call returns immediately; Otherwise the current thread becomes disabled for thread scheduling purposes and lies dormant until one of four things hap Pens
- Some other thread invokes with the current thread as the
unpark target;
- Some other thread interrupts the current thread; Or
- The specified deadline passes; Or
- The call spuriously (that's, for no reason) returns.
This method does the which of these caused the method to return. Callers should re-check the conditions which caused the thread to park in the first place. Callers may also determine, for example, the interrupt status of the thread, or the current time upon return.
-
Parameters:
-
deadline -The absolute time, in milliseconds from the Epoch, to wait until
Java Process State