The lifecycle of a thread in Java defines the various states a thread goes through from its creation to termination. Understanding these states helps in managing thread behavior and synchronization in multithreaded applications.
- A thread passes through multiple states during execution
- The thread scheduler controls state transitions
- Helps in efficient thread management and debugging

There are multiple states of the thread in a lifecycle as mentioned below
1. NewÂ
A thread is in the new state when it is created but has not yet started execution, so its code has not begun running.
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
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.