static class Var implements IVar { A v; // you can access this directly if you use one thread *() {} *(A *v) {} public synchronized void set(A a) { if (v != a) { v = a; notifyAll(); } } public synchronized A get() { ret v; } public synchronized bool has() { ret v != null; } public synchronized void clear() { v = null; } }