Java in a Nutshell, 5th Edition [Electronic resources]

نسخه متنی -صفحه : 1191/ 813
نمايش فراداده

AtomicIntegerFieldUpdater<T>java.util.concurrent.atomic

Java 5.0

This class uses java.lang.reflect to provide atomic operations for named volatile int fields within existing types. Obtain an instance of this class with the newUpdater( ) factory method. Pass the name of the field (which must have been declared volatile int) to be updated and the class that it is defined within to this factory method. The instance methods of the resulting AtomicIntegerFieldUpdater object are like those of the AtomicInteger class but require you to specify the object whose field is to be manipulated. This is a generic type, and the type variable T represents the type whose volatile int field is being updated.

public abstract class

AtomicIntegerFieldUpdater<T> { // Protected Constructors protected

AtomicIntegerFieldUpdater ( ); // Public Class Methods public static <U> AtomicIntegerFieldUpdater<U>

newUpdater (Class<U>

tclass , String

fieldName ); // Public Instance Methods public int

addAndGet (T

obj , int

delta ); public abstract boolean

compareAndSet (T

obj , int

expect , int

update ); public int

decrementAndGet (T

obj ); public abstract int

get (T

obj ); public int

getAndAdd (T

obj , int

delta ); public int

getAndDecrement (T

obj ); public int

getAndIncrement (T

obj ); public int

getAndSet (T

obj , int

newValue ); public int

incrementAndGet (T

obj ); public abstract void

set (T

obj , int

newValue ); public abstract boolean

weakCompareAndSet (T

obj , int

expect , int

update ); }