javatutelearn.com

Easy Learning


Home

Search Javatutelearn.com :



isAlive() method of thread

  • The isAlive() method checks whether a thread is running. This method returns true if thread is running, otherwise it returns false.

Syntax

public final boolean isAlive()

Example

 public class  MyThread extends Thread {
    public void  run(){
        System.out.println("Thread name "+Thread.currentThread().getName());
    }
    public static void  main(String args[]) {
        
        MyThread t1 = new MyThread();
        
        t1.start();
        
        System.out.println("Status : "+ t1.isAlive());
        
    }
}

Output

Status : true
Thread name Thread-0





© Copyright 2016-2024 by javatutelearn.com. All Rights Reserved.