User an AtomicReference instead of a synchronized block