A v; // you can access this directly if you use one thread 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 void clear() { set(null); }