public void testReusableThread() {
ReusableThread t=new ReusableThread("Demo ReusableThread");
MyThread m1=new MyThread(1);
MyThread m2=new MyThread(2);
LongRunningThread m4=new LongRunningThread(4);
System.out.println("Assigning task");
t.assignTask(m4);
System.out.println("Sleeping 2 secs");
Util.sleep(2000);
System.out.println("stop()");
t.stop();
System.out.println("stop() -- done");
Util.printThreads();
System.out.println("\nAssigning task 1");
t.assignTask(m1);
t.waitUntilDone(); // passive wait
System.out.println("done with task 1");
Util.printThreads();
System.out.println("\nAssigning task 2");
t.assignTask(m2);
t.waitUntilDone();
System.out.println("done with task 2");
System.out.println("Stopping thread");
t.stop();
System.out.println("done");
Util.printThreads();
}