FileDocCategorySizeDatePackage
BusyFlag.javaAPI DocExample2115Thu Mar 11 22:29:04 GMT 2004javathreads.examples.appa

BusyFlag

public class BusyFlag extends Object

Fields Summary
protected Thread
busyflag
protected int
busycount
Constructors Summary
Methods Summary
public synchronized voidfreeBusyFlag()

		if (getBusyFlagOwner() == Thread.currentThread()) {
			busycount--;
			if (busycount == 0) {
				busyflag = null;
				notify();
			}
		}
	
public synchronized voidgetBusyFlag()


	    
		while (tryGetBusyFlag() == false) {
			try {
				wait();
			} catch (Exception e) {}
		}
	
public synchronized java.lang.ThreadgetBusyFlagOwner()

		return busyflag;
	
public synchronized booleantryGetBusyFlag()

		if (busyflag == null) {
			busyflag = Thread.currentThread();
			busycount = 1;
			return true;
		}
		if (busyflag == Thread.currentThread()) {
			busycount++;
			return true;
		}
		return false;