Code example for AtomicReference

Methods: getAndSet

0
            value = new AtomicReference<T>(t);
            timestamp = System.currentTimeMillis();
        } 
         
        public boolean setNewValue(T newValue, double confidence, long timestamp) {
            if(value.getAndSet(newValue) != newValue) {
                this.confidence = confidence;
                this.timestamp = timestamp;
                return true; 
            } else { 
                return false; 
            } 
        } 
    } 
     
    public StateDetails<ScreenRegion> gazeRegion;
    public StateDetails<FacialExpression> expression;
    public ConcurrentMap<String, ScreenRegion> objectRegions;
 
    private State() {