start(), sleep(), wait(), or when the thread finishes execution.
start() is called.
MyThread t1 = new MyThread(); // thread created, but not started
If you directly call run() instead of start(), it executes as a normal method, not a separate thread.
start(), the thread moves to Runnable.
t1.start(); // moves from New -> Runnable state
Thread is managed by the Thread Scheduler.
run() method.
public void run()
{
System.out.println("Thread is running...");
}
wait(), sleep(), join(), or waiting for a lock.
Thread.sleep(2000); // timed waiting
obj.wait(); // waiting
run() method finishes and the thread enters Dead state.
start().
| Thread State | Description | How to Enter This State |
|---|---|---|
| 1. New | Thread is created but not yet started. | Thread object is instantiated using new Thread(). |
| 2. Runnable | Thread is ready to run and waiting for CPU allocation. | Calling start() on the thread. |
| 3. Running | Thread is currently executing its run() method. |
Thread scheduler allocates CPU to the thread. |
| 4. Non-Runnable | Thread is currently in inactive state. | Calling wait(), sleep() etc methods. |
| 5. Terminated | Thread has finished execution or has been stopped. | run() method completes execution. |
Your feedback helps us grow! If there's anything we can fix or improve, please let us know.
Weβre here to make our tutorials better based on your thoughts and suggestions.