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