Reentrantpublic class Reentrant extends Thread Illustrate the following quotation:
"Threads are re-entrant. A given thread can acquire the same
monitor several times..."
|
Methods Summary |
---|
public static void | main(java.lang.String[] argv)Main program, test driver for ThreadSync class.
Thread t = new Reentrant();
t.start();
try {
t.join();
} catch (InterruptedException ex) {
//
}
System.out.println("All done.");
| public synchronized void | run()Run does the work: print a message, "count" number of times
while (count-- > 0) {
System.out.println("Count = " + count);
run();
}
|
|