How to execute a thread in Java

1 Answer

0 votes
public class T extends Thread  
{  
    public void run() {  
        try {  
              System.out.println("thread execute");  
        } catch(Exception e) { 
            System.out.println("Exception");  
          }   
    }  
    public static void main (String[] args) {  
        T tr = new T();  
        tr.start();  
    }
}  

 
 
/*
run:
 
thread execute
 
*/

 



answered Sep 28, 2019 by avibootz
edited Sep 28, 2019 by avibootz

Related questions

1 answer 79 views
1 answer 202 views
1 answer 292 views
...