sclass BoolVar { bool a; // you can access this directly if you use one thread public synchronized void set(bool a default true) { if (v != a) { v = a; notifyAll(); } } public synchronized bool get() { ret v; } //public synchronized bool has() { true; } public synchronized void clear() { set(false); } bool waitUntilTrue () { ret waitForValue(true); } bool waitUntilFalse() { ret waitForValue(false); } synchronized bool waitForValue(bool wantedValue) { while (b != wantedValue) wait(); ret b; } }