class NewThread implements Runnable { private String msg; public NewThread(String s) { msg = s; } // Interface method public void run() { System.out.println(msg); } } public class ThreadDemo1 { public static void main(String args[]) throws InterruptedException { Runnable p1, p2, p3, p4; Thread t1, t2, t3, t4; p1 = new NewThread("Hello"); p2 = new NewThread("Bye"); p3 = new NewThread("ABC"); p4 = new NewThread("123"); t1 = new Thread(p1); t2 = new Thread(p2); t3 = new Thread(p3); t4 = new Thread(p4); t1.start(); t2.start(); t3.start(); t4.start(); System.out.println("Waiting for threads to exit"); t1.join(); t2.join(); t3.join(); t4.join(); System.out.println("Done"); } }