class MyThread extends Thread { private int count; public MyThread(String msg, int count) { super(msg); // Optional thread name this.count = count; } public void run() { for (int i = 0; i < count; ++i) System.out.println(getName()); } } class Independent { public static void main(String[] args) { Thread t1 = new MyThread("DessertTopping", 8); Thread t2 = new MyThread("FloorWax", 4); t1.start(); t2.start(); } } /* Output: DessertTopping DessertTopping DessertTopping DessertTopping DessertTopping DessertTopping DessertTopping FloorWax FloorWax FloorWax FloorWax DessertTopping */ End of Listing