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

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

There is a newer version: 1.7.0
Show newest version
package com.beans.properties.atomic;

import com.beans.properties.IntPropertyBase;

/**
 * 

* A thread-safe implementation of {@link com.beans.IntProperty IntProperty}, holding a * variable which is accessed for writing or reading through {@link #setAsInt(int)} * and {@link #getAsInt()}. *

*

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




© 2015 - 2024 Weber Informatics LLC | Privacy Policy