All pastes #732315 Raw Edit

Someone

public java v1 · immutable
·published 2007-10-10 21:21 UTC
rendered paste body
public class Monitor {	private boolean locked;	public Monitor() {		this.locked = true;	}	public void lock() {		this.locked = true;	}	public void unlock() {		this.locked = false;	}	public boolean isLocked() {		return this.locked;	}	public void unlockAndNotify() {		this.unlock();		this.notify();	}		public void timedWait(int timeout) throws InterruptedException {				long abortTime = Timing.currentTime() + timeout;				while (isLocked() && Timing.currentTime() < abortTime)			wait(abortTime - Timing.currentTime());	}		public void untimedWait() throws InterruptedException {				while (isLocked())			wait();	}}