Thread life cycle:
1. New: A new thread is created but not working. A thread after creation and before invocation of start() method will be in new state.
2. Runnable: A thread after invocation of start() method will be in runnable state. A thread in runnable state will be available for thread scheduler.
3. Running: A thread in execution after thread scheduler select it, it will be in running state.
4. Blocked: A thread which is alive but not in runnable or running state will be in blocked state. A thread can be in blocked state because of suspend(), sleep(), wait() methods or implicitly by JVM to perform I/O operations.
5. Dead: A thread after exiting from run() method will be in dead state. We can use stop() method to forcefully killed a thread.
Next Topic: Multithreading in java.
Previous Topic: Commonly used exception methods of Throwable class in java.
- Multithreading in java.
- Thread life cycle in java.
- Way of creating thread in java.
- Which is a better way to create a thread in java?
- Commonly used methods of Thread class.
- Difference between thread start and run method.
- Why we call start method in thread?
- Can we override start method?
- Can we override run method?
- Can we start a thread twice?
- Thread scheduling in java with example.
- Thread priority in java with example.
- Naming a thread in java with example.
- Joining a thread in java with example.
- How to get current thread in java?
- Daemon thread in java with example.
- Can we call run method directly?
- Difference between Thread.yield() and Thread.sleep() methods.
- Deadlock in java with example.
- Starvation in java with example.
- Inter-thread communication in java with example.
- Synchronization in java with example.
- Synchronized method in java with example.
- Static synchronization in java with example.
- Synchronized block in java with example.