Name

Thread.State

Synopsis

This enumerated type defines the possible states of a thread. Call the getState( ) method of a Thread object to obtain one of the enumerated constants defined here. A NEW thread has not been started yet, and a TERMINATED thread has exited. A BLOCKED thread is waiting to enter a synchronized method or block. A WAITING thread is waiting in Object.wait( ), Thread.join( ), or a similar method. A TIMED_WAITING thread is waiting but is subject to a timeout, such as in Thread.sleep( ) or the timed versions of Object.wait( ) and Thread.join( ). Finally, a thread that has been started and has not yet exited and is not blocked or waiting is RUNNABLE . This does not mean that the operating system is currently running it or that it is even making any forward progress, but that it is at least available to run when the operating system gives it the CPU.

public enum Thread.State {
// Enumerated Constants
                  NEW,  
     RUNNABLE,  
     BLOCKED,  
     WAITING,  
     TIMED_WAITING,  
     TERMINATED;  
// Public Class Methods
     public static Thread.State valueOf(String name);  
     public static final Thread.State[ ] values( );  
}

Returned By

Thread.getState( ), java.lang.management.ThreadInfo.getThreadState( )

Get Java in a Nutshell, 5th Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.