Tutoriallearn.com

Easy Learning


Home

Search Tutoriallearn.com :



getId() method of thread

    getId() method returns thread identifier. It is a unique positive number. It is generated at the time of thread creation.

Example

 public class  ExampID1  extends  Thread {
    
    public void  run(){
        System.out.println( "Thread id is "+Thread.currentThread().getId());
    }

    public static void  main(String[] args) {
       
      ExampID1 t1 = new ExampID1();
      
      t1.start();
   }
}

Output

Thread id is 11






© Copyright 2016-2026 by tutoriallearn.com. All Rights Reserved.