FileDocCategorySizeDatePackage
DaemonLock.javaAPI DocExample1814Mon Mar 15 21:47:18 GMT 2004javathreads.examples.appa

DaemonLock

public class DaemonLock extends Object implements Runnable

Fields Summary
private int
lockCount
Constructors Summary
Methods Summary
public synchronized voidacquire()


	    
		if (lockCount++ == 0) {
			Thread t = new Thread(this);
			t.setDaemon(false);
			t.start();
		}
	
public synchronized voidrelease()

		if (--lockCount == 0) {
			notify();
		} 
	
public synchronized voidrun()

		while (lockCount != 0) {
			try {
				wait();
			} catch (InterruptedException ex) {};
		}