FileDocCategorySizeDatePackage
Reentrant.javaAPI DocExample696Tue Jun 18 16:29:46 BST 2002None

Reentrant

public class Reentrant extends Thread
Illustrate the following quotation:
"Threads are re-entrant. A given thread can acquire the same monitor several times..."
author
Ian Darwin

Fields Summary
int
count
Constructors Summary
Methods Summary
public static voidmain(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 voidrun()
Run does the work: print a message, "count" number of times


	             
	    
		while (count-- > 0) {
			System.out.println("Count = " + count);
			run();
		}