FileDocCategorySizeDatePackage
QueuedBusyFlag.javaAPI DocExample2239Thu Feb 04 16:10:40 GMT 1999None

QueuedBusyFlag

public class QueuedBusyFlag extends BusyFlag

Fields Summary
protected Vector
waiters
Constructors Summary
public QueuedBusyFlag()

		waiters = new Vector();
	
Methods Summary
public synchronized voidfreeBusyflag()

		if (Thread.currentThread() != busyflag)
			throw new IllegalArgumentException("QueuedBusyflag not held");
		if (busycount == 0) {
			waiters.removeElementAt(0);
			notifyAll();
			busyflag = null;
		}
		else busycount--;
	
public synchronized voidgetBusyFlag()

		Thread me = Thread.currentThread();
		if (me == busyflag) {
			busycount++;
			return;
		}
		waiters.addElement(me);
		while ((Thread) waiters.elementAt(0) != me) {
			try {
				wait();
			} catch (Exception e) {}
		}
		busyflag = me;
		busycount = 0;
	
public synchronized booleantryGetBusyflag()

		if (waiters.size() != 0 && busyflag != Thread.currentThread())
			return false;
		getBusyFlag();
		return true;