I think you need T <: AnyRef here for AtomicReference to actually work correctly (since it deals with reference equality).