# Thread.State

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)

# State

```
class State
```

|---|---|--------------------------------------------------------------------------------------------------|
| [kotlin.Any](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html)                      |||
| ↳ | [kotlin.Enum](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-enum/index.html)\<[java.lang.Thread.State](https://developer.android.com/reference/kotlin/java/lang/Thread.State#)\> ||
|   | ↳ | [java.lang.Thread.State](https://developer.android.com/reference/kotlin/java/lang/Thread.State#) |

|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| Known Direct Subclasses [Thread.State.BLOCKED](https://developer.android.com/reference/kotlin/java/lang/Thread.State#ENUM_VALUE:BLOCKED),[Thread.State.NEW](https://developer.android.com/reference/kotlin/java/lang/Thread.State#ENUM_VALUE:NEW),[Thread.State.RUNNABLE](https://developer.android.com/reference/kotlin/java/lang/Thread.State#ENUM_VALUE:RUNNABLE),[Thread.State.TERMINATED](https://developer.android.com/reference/kotlin/java/lang/Thread.State#ENUM_VALUE:TERMINATED),[Thread.State.TIMED_WAITING](https://developer.android.com/reference/kotlin/java/lang/Thread.State#ENUM_VALUE:TIMED_WAITING),[Thread.State.WAITING](https://developer.android.com/reference/kotlin/java/lang/Thread.State#ENUM_VALUE:WAITING) |------------------------------------------------------------------------------------------------------------------------------|------------------------------------------------------------------| | [Thread.State.BLOCKED](https://developer.android.com/reference/kotlin/java/lang/Thread.State#ENUM_VALUE:BLOCKED)             | Thread state for a thread blocked waiting for a monitor lock.    | | [Thread.State.NEW](https://developer.android.com/reference/kotlin/java/lang/Thread.State#ENUM_VALUE:NEW)                     | Thread state for a thread which has not yet started.             | | [Thread.State.RUNNABLE](https://developer.android.com/reference/kotlin/java/lang/Thread.State#ENUM_VALUE:RUNNABLE)           | Thread state for a runnable thread.                              | | [Thread.State.TERMINATED](https://developer.android.com/reference/kotlin/java/lang/Thread.State#ENUM_VALUE:TERMINATED)       | Thread state for a terminated thread.                            | | [Thread.State.TIMED_WAITING](https://developer.android.com/reference/kotlin/java/lang/Thread.State#ENUM_VALUE:TIMED_WAITING) | Thread state for a waiting thread with a specified waiting time. | | [Thread.State.WAITING](https://developer.android.com/reference/kotlin/java/lang/Thread.State#ENUM_VALUE:WAITING)             | Thread state for a waiting thread.                               | |

A thread state. A thread can be in one of the following states:

- [NEW](https://developer.android.com/reference/kotlin/java/lang/Thread.State#)  
  A thread that has not yet started is in this state.
- [RUNNABLE](https://developer.android.com/reference/kotlin/java/lang/Thread.State#)  
  A thread executing in the Java virtual machine is in this state.
- [BLOCKED](https://developer.android.com/reference/kotlin/java/lang/Thread.State#)  
  A thread that is blocked waiting for a monitor lock is in this state.
- [WAITING](https://developer.android.com/reference/kotlin/java/lang/Thread.State#)  
  A thread that is waiting indefinitely for another thread to perform a particular action is in this state.
- [TIMED_WAITING](https://developer.android.com/reference/kotlin/java/lang/Thread.State#)  
  A thread that is waiting for another thread to perform an action for up to a specified waiting time is in this state.
- [TERMINATED](https://developer.android.com/reference/kotlin/java/lang/Thread.State#)  
  A thread that has exited is in this state.

<br />

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.

## Summary

|                                                                                     Enum values                                                                                     ||
|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---|
| [BLOCKED](https://developer.android.com/reference/kotlin/java/lang/Thread.State#ENUM_VALUE:BLOCKED) Thread state for a thread blocked waiting for a monitor lock.                |
| [NEW](https://developer.android.com/reference/kotlin/java/lang/Thread.State#ENUM_VALUE:NEW) Thread state for a thread which has not yet started.                                 |
| [RUNNABLE](https://developer.android.com/reference/kotlin/java/lang/Thread.State#ENUM_VALUE:RUNNABLE) Thread state for a runnable thread.                                        |
| [TERMINATED](https://developer.android.com/reference/kotlin/java/lang/Thread.State#ENUM_VALUE:TERMINATED) Thread state for a terminated thread.                                  |
| [TIMED_WAITING](https://developer.android.com/reference/kotlin/java/lang/Thread.State#ENUM_VALUE:TIMED_WAITING) Thread state for a waiting thread with a specified waiting time. |
| [WAITING](https://developer.android.com/reference/kotlin/java/lang/Thread.State#ENUM_VALUE:WAITING) Thread state for a waiting thread.                                           |

## Enum values

### BLOCKED

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
enum val BLOCKED : Thread.State
```

Thread state for a thread blocked waiting for a monitor lock. A thread in the blocked state is waiting for a monitor lock to enter a synchronized block/method or reenter a synchronized block/method after calling[Object.wait](https://developer.android.com/reference/kotlin/java/lang/Object#wait()).  

### NEW

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
enum val NEW : Thread.State
```

Thread state for a thread which has not yet started.  

### RUNNABLE

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
enum val RUNNABLE : Thread.State
```

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 processor.  

### TERMINATED

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
enum val TERMINATED : Thread.State
```

Thread state for a terminated thread. The thread has completed execution.  

### TIMED_WAITING

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
enum val TIMED_WAITING : Thread.State
```

Thread state for a waiting thread with a specified waiting time. A thread is in the timed waiting state due to calling one of the following methods with a specified positive waiting time:

- sleep
- [Object.wait](https://developer.android.com/reference/kotlin/java/lang/Object#wait(kotlin.Long))with timeout
- [Thread.join](https://developer.android.com/reference/kotlin/java/lang/Thread#join(kotlin.Long))with timeout
- java.util.concurrent.locks.LockSupport#parkNanos
- java.util.concurrent.locks.LockSupport#parkUntil

<br />

### WAITING

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
enum val WAITING : Thread.State
```

Thread state for a waiting thread. A thread is in the waiting state due to calling one of the following methods:

- [Object.wait](https://developer.android.com/reference/kotlin/java/lang/Object#wait())with no timeout
- [Thread.join](https://developer.android.com/reference/kotlin/java/lang/Thread#join())with no timeout
- [LockSupport.park](https://developer.android.com/reference/kotlin/java/util/concurrent/locks/LockSupport.html#park())

<br />

A thread in the waiting state is waiting for another thread to perform a particular action. For example, a thread that has called`Object.wait()`on an object is waiting for another thread to call`Object.notify()`or`Object.notifyAll()`on that object. A thread that has called`Thread.join()`is waiting for a specified thread to terminate.