All pastes #733297 Raw Edit

Anonymous

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