How do I get the state of a thread?

To get the state of a thread use getState() method of a Thread class. One thing to be noted is that this method is designed for use in monitoring of the system state, not for synchronization control.

package org.kodejava.example.lang;

public class GetThreadState implements Runnable {
    public void run() {

    public static void main(String[] args) {
        Thread thread = new Thread(new GetThreadState());

        // Get the state of the thread.
        Thread.State state = thread.getState();
        System.out.println("State: " +;

Wayan Saryada

Founder at Kode Java Org
I am a programmer, a runner, a recreational diver, currently live in the island of Bali, Indonesia. Mostly programming in Java, Spring Framework, Hibernate / JPA. You can support my works by donating here. Thank you 🥳

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.