How to create a thread by implementing a Runnable interface in Java

1 Answer

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

 



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