How to Display all Threads Status in Java? Last Updated : 23 Jul, 2025 Suggest changes Share Like Article Like Report Threads are light-weight processes within a process.. Multithreading in java is a feature that allows concurrent execution of two or more parts of a program to maximize the utilization of CPU. here the approach to retrieve the state of the thread is via getState() method of the Thread class. A java thread can exist in any one of the following states, the status of a thread is the state in which it exists at a given instance. The life cycle of a thread as shown above is the best way out to learn more about the states where the states are as follows: NewRunnableBlockedWaitingTimed WaitingTerminated Note: When a thread is getting executed all other threads are in blocking state and not in waiting state. Procedure: Displaying thread status Threads are created by implementing the runnable interface.The status of a thread can be retrieved by getState() method of the Thread class object. Example: Java // Java Program to Display all Threads Status // Importing Set class from java.util package import java.util.Set; // Class 1 // helper Class implementing Runnable interface class MyThread implements Runnable { // run() method whenever thread is invoked public void run() { // Try block to check for exceptions try { // making thread to Thread.sleep(2000); } // Catch block to handle the exceptions catch (Exception err) { // Print the exception System.out.println(err); } } } // Class 2 // Main Class to check thread status public class GFG { // Main driver method public static void main(String args[]) throws Exception { // Iterating to create multiple threads // Customly creating 5 threads for (int thread_num = 0; thread_num < 5; thread_num++) { // Creating single thread object Thread t = new Thread(new MyThread()); // Setting name of the particular thread // using setName() method t.setName("MyThread:" + thread_num); // Starting the current thread // using start() method t.start(); } // Creating set object to hold all the threads where // Thread.getAllStackTraces().keySet() returns // all threads including application threads and // system threads Set<Thread> threadSet = Thread.getAllStackTraces().keySet(); // Now, for loop is used to iterate through the // threadset for (Thread t : threadSet) { // Printing the thread status using getState() // method System.out.println("Thread :" + t + ":" + "Thread status : " + t.getState()); } } } Output: P pulamolusaimohan Follow Article Tags : Java Java Programs Java-Multithreading Explore Java BasicsIntroduction to Java3 min readJava Programming Basics9 min readJava Methods6 min readAccess Modifiers in Java4 min readArrays in Java7 min readJava Strings8 min readRegular Expressions in Java3 min readOOP & InterfacesClasses and Objects in Java9 min readAccess Modifiers in Java4 min readJava Constructors10 min readJava OOP(Object Oriented Programming) Concepts10 min readJava Packages7 min readJava Interface7 min readCollectionsCollections in Java12 min readCollections Class in Java13 min readCollection Interface in Java4 min readIterator in Java5 min readJava Comparator Interface6 min readException HandlingJava Exception Handling6 min readJava Try Catch Block4 min readJava final, finally and finalize4 min readChained Exceptions in Java3 min readNull Pointer Exception in Java5 min readException Handling with Method Overriding in Java4 min readJava AdvancedJava Multithreading Tutorial3 min readSynchronization in Java10 min readFile Handling in Java4 min readJava Method References9 min readJava 8 Stream Tutorial7 min readJava Networking6 min readJDBC Tutorial5 min readJava Memory Management4 min readGarbage Collection in Java6 min readMemory Leaks in Java3 min readPractice JavaJava Interview Questions and Answers15+ min readJava Programs - Java Programming Examples7 min readJava Exercises - Basic to Advanced Java Practice Programs with Solutions5 min readJava Quiz1 min readJava Project Ideas For Beginners and Advanced15+ min read My Profile ${profileImgHtml} My Profile Edit Profile My Courses Join Community Transactions Logout Like