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

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

package com.beans.properties.atomic;

import com.beans.properties.LongPropertyBase;

/**
 * 

* A thread-safe implementation of {@link com.beans.LongProperty LongProperty}, holding a * variable which is accessed for writing or reading through {@link #setAsLong(long)} * and {@link #getAsLong()}. *

*

* A boxed version of the access interface for writing and reading is available * using {@link #set(Long)} 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 AtomicLongProperty extends LongPropertyBase { private volatile long mValue; public AtomicLongProperty(long value) { mValue = value; } /** * Initializes the property with a value of 0. */ public AtomicLongProperty() { this(0); } @Override public void setAsLong(long value) { mValue = value; } @Override public long getAsLong() { return mValue; } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy