Code example for AtomicReference

Methods: get, set

0
        this.value = new AtomicReference<T>(key.getDefaultValue());
    } 
 
    public T get() 
    { 
        return value.get();
    } 
 
    public T set(T newValue)
    { 
        if (newValue == null)
        { 
            throw new NullPointerException("newValue shoudl not be null");
        } 
        T oldValue = get();
        value.set(newValue);
        return oldValue;
    } 
 
    /* 
     * (non-Javadoc)