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