The lifecycle of a thread in Java describes the different states a thread goes through from its creation until its execution is completed.
- A thread moves between different states during its lifetime.
- Thread methods such as start(), sleep(), wait(), and join() can cause state transitions.
- Understanding thread states helps in debugging and managing multithreaded applications.
Thread Lifecycle
A thread generally moves through the following states:

1. New
A thread is in the NEW state when its Thread object has been created but the start() method has not yet been called.
public static final Thread.State NEW
2. 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.
public static final Thread.State RUNNABLE
3. Blocked
A thread is in the blocked state when it is waiting to acquire a lock that is currently held by another thread.
public static final Thread.State BLOCKED
4. Waiting
Thread state for a waiting thread. 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
public static final Thread.State WAITING
5. Timed Waiting
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:
- Thread.sleep
- Object.wait with timeout
- Thread.join with timeout
- LockSupport.parkNanos
- LockSupport.parkUntil
public static final Thread.State TIMED_WAITING
6. Terminated
Thread state for a terminated thread. The thread has completed execution.
public static final Thread.State TERMINATED
Important Thread Methods and States
| Method | Effect |
|---|---|
start() | Starts a new thread and moves it from NEW toward RUNNABLE |
sleep() | Puts the current thread into TIMED_WAITING |
wait() | Releases the monitor and puts the thread into WAITING |
join() | Makes one thread wait for another thread to finish |
| interrupt() | Requests interruption; the resulting state depends on what the thread is doing |
| getState() | Returns the current thread state |
Note: Calling run() directly does not start a new thread. It executes run() like a normal method call in the current thread. Use start() to create a new thread of execution.
WAITING Vs TIMED_WAITING
| WAITING | TIMED_WAITING |
|---|---|
| Waits indefinitely | Waits for a specified time |
wait() | sleep() |
join() | join(timeout) |
| LockSupport.park() | wait(timeout) |
| No timeout is specified | Timeout is specified |
Example: Demonstrate thread states using a ticket booking scenario
class TicketBooking implements Runnable {
@Override
public void run() {
try {
// Timed waiting
Thread.sleep(200);
} catch (InterruptedException e) {
e.printStackTrace();
}
System.out.println("State of bookingThread while mainThread is waiting: " +
TicketSystem.mainThread.getState());
try {
// Another timed waiting
Thread.sleep(100);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
public class TicketSystem implements Runnable {
public static Thread mainThread;
public static TicketSystem ticketSystem;
@Override
public void run() {
TicketBooking booking = new TicketBooking();
Thread bookingThread = new Thread(booking);
System.out.println("State after creating bookingThread: " + bookingThread.getState());
bookingThread.start();
System.out.println("State after starting bookingThread: " + bookingThread.getState());
try {
Thread.sleep(100);
} catch (InterruptedException e) {
e.printStackTrace();
}
System.out.println("State after sleeping bookingThread: " + bookingThread.getState());
try {
// Moves mainThread to waiting state
bookingThread.join();
} catch (InterruptedException e) {
e.printStackTrace();
}
System.out.println("State after bookingThread finishes: " + bookingThread.getState());
}
public static void main(String[] args) {
ticketSystem = new TicketSystem();
mainThread = new Thread(ticketSystem);
System.out.println("State after creating mainThread: " + mainThread.getState());
mainThread.start();
System.out.println("State after starting mainThread: " + mainThread.getState());
}
}
Output:

Explanation:
- When a new thread is created, the thread is in the NEW state. When the start() method is called on a thread, the thread scheduler moves it to the Runnable state.
- Whenever the join() method is called on a thread instance, the main thread goes to Waiting for the booking thread to complete.
- Once the thread's run method completes, its state becomes Terminated.
Advantages of Understanding Thread Lifecycle
- Helps understand how threads behave during execution.
- Makes it easier to manage multiple threads efficiently.
- Helps identify why a thread is waiting or blocked.
- Makes debugging multithreaded applications easier.
- Helps prevent unnecessary resource usage.
- Improves understanding of thread synchronization.
- Helps choose the appropriate thread method for a particular task.
- Makes it easier to identify and resolve thread-related issues.