How to create a thread by extending the Thread class in Java

1 Answer

0 votes
public class Program extends Thread {
    public static void main(String[] args) {
        Program thrd = new Program();
 
        thrd.start();
 
        System.out.println("After thread");
    }
 
    public void run() {
        System.out.println("Thread run");
    }
}
 
 
 
/*
run:
 
After thread
Thread run
 
*/

 

 



answered Jan 28, 2024 by avibootz
edited Jan 29, 2024 by avibootz

Related questions

1 answer 190 views
1 answer 224 views
1 answer 217 views
1 answer 248 views
...