All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.beans.properties.atomic.AtomicDoubleProperty Maven / Gradle / Ivy

package com.beans.properties.atomic;

import com.beans.properties.DoublePropertyBase;

/**
 * 

* A thread-safe implementation of {@link com.beans.DoubleProperty DoubleProperty}, holding a * variable which is accessed for writing or reading through {@link #setAsDouble(double)} * and {@link #getAsDouble()}. *

*

* A boxed version of the access interface for writing and reading is available * using {@link #set(Double)} and {@link #get()}, which are basically proxies * for the primitive interface. *

*

* This implementation relays on the fact that the Java Language Specifications guarantee that an access (read/write) * to a volatile field is atomic, and will be visible to all threads. *

* * @since JavaBeans 1.0 */ public class AtomicDoubleProperty extends DoublePropertyBase { private volatile double mValue; public AtomicDoubleProperty(double value) { mValue = value; } /** * Initializes the property with a value of 0. */ public AtomicDoubleProperty() { this(0.0); } @Override public void setAsDouble(double value) { mValue = value; } @Override public double getAsDouble() { return mValue; } @Override public String toString() { return String.valueOf(mValue); } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy