See:
Description
| Class Summary | |
|---|---|
| AtomicBoolean | A boolean value that may be updated atomically. |
| AtomicInteger | An int value that may be updated atomically. |
| AtomicIntegerArray | An int array in which elements may be updated atomically. |
| AtomicIntegerFieldUpdater<T> | A reflection-based utility that enables atomic updates to designated volatile int fields of designated classes. |
| AtomicLong | A long value that may be updated atomically. |
| AtomicLongArray | A long array in which elements may be updated atomically. |
| AtomicLongFieldUpdater<T> | A reflection-based utility that enables atomic updates to designated volatile long fields of designated classes. |
| AtomicMarkableReference<V> | An AtomicMarkableReference maintains an object reference along with a mark bit, that can be updated atomically. |
| AtomicReference<V> | An object reference that may be updated atomically. |
| AtomicReferenceArray<E> | An array of object references in which elements may be updated atomically. |
| AtomicReferenceFieldUpdater<T,V> | A reflection-based utility that enables atomic updates to designated volatile reference fields of designated classes. |
| AtomicStampedReference<V> | An AtomicStampedReference maintains an object reference along with an integer "stamp", that can be updated atomically. |
A small toolkit of classes that support lock-free thread-safe programming on single variables. In essence, the classes in this package extend the notion of volatile values, fields, and array elements to those that also provide an atomic conditional update operation of the form:
boolean compareAndSet(expectedValue, updateValue);
This method (which varies in argument types across different classes) atomically sets a variable to the updateValue if it currently holds the expectedValue, reporting true on success. The classes in this package also contain methods to get and unconditionally set values, as well as a weaker conditional atomic update operation weakCompareAndSet. The weak version may be more efficient in the normal case, but differs in that any given invocation of weakCompareAndSet method may fail, even spuriously (that is, for no apparent reason). A false return means only that the operation may be retried if desired, relying on the guarantee that repeated invocation when the variable holds expectedValue and no other thread is also attempting to set the variable will eventually succeed.
The specifications of these methods enable implementations to employ efficient machine-level atomic instructions that are available on contemporary processors. However on some platforms, support may entail some form of internal locking. Thus the methods are not strictly guaranteed to be non-blocking -- a thread may block transiently before performing the operation.
Instances of classes AtomicBoolean, AtomicInteger, AtomicLong, and AtomicReference each provide access and
updates to a single variable of the corresponding type. Each class
also provides appropriate utility methods for that type. For example,
classes AtomicLong and AtomicInteger provide atomic
increment methods. One application is to generate sequence numbers,
as in:
public long next() { return sequenceNumber.getAndIncrement(); } }
The memory effects for accesses and updates of atomics generally follow the rules for volatiles:
In addition to classes representing single values, this package
contains Updater classes that can be used to obtain
compareAndSet operations on any selected volatile
field of any selected class. AtomicReferenceFieldUpdater, AtomicIntegerFieldUpdater, and AtomicLongFieldUpdater are
reflection-based utilities that provide access to the associated field
types. These are mainly of use in atomic data structures in which
several volatile fields of the same node (for example, the
links of a tree node) are independently subject to atomic
updates. These classes enable greater flexibility in how and when to
use atomic updates, at the expense of more awkward reflection-based
setup, less convenient usage, and weaker guarantees.
The AtomicIntegerArray, AtomicLongArray, and AtomicReferenceArray classes further
extend atomic operation support to arrays of these types. These
classes are also notable in providing volatile access
semantics for their array elements, which is not supported for
ordinary arrays.
The AtomicMarkableReference
class associates a single boolean with a reference. For example, this
bit might be used inside a data structure to mean that the object
being referenced has logically been deleted. The AtomicStampedReference class associates
an integer value with a reference. This may be used for example, to
represent version numbers corresponding to series of updates.
Atomic classes are designed primarily as building blocks for implementing non-blocking data structures and related infrastructure classes. The compareAndSet method is not a general replacement for locking. It applies only when critical updates for an object are confined to a single variable.
Atomic classes are not general purpose replacements for java.lang.Integer and related classes. They do not define methods such as hashCode and compareTo. (Because atomic variables are expected to be mutated, they are poor choices for hash table keys.) Additionally, classes are provided only for those types that are commonly useful in intended applications. For example, there is no atomic class for representing byte. In those infrequent cases where you would like to do so, you can use an AtomicInteger to hold byte values, and cast appropriately. You can also hold floats using Float.floatToIntBits and Float.intBitstoFloat conversions, and doubles using Double.doubleToLongBits and Double.longBitsToDouble conversions.
Ces informations proviennent du site de http://java.sun.com
Le contenu de cette page provient du site de Sun, et est généré depuis un cache sur l'infobrol après certains traitements automatisés. La présentation peut donc différer du document original, mais le contenu aussi. Vous pouvez utiliser ce bouton pour afficher la page originale du site de Sun :
Maintenir les pages en cache sur différents sites peut offrir plus de disponibilité.
Chaque page est indexée dans la base de donnée, ce qui permet de retrouver facilement les informations, au moyen des sommaires, du moteur de recherche interne, etc.
Des facilités sont mises en place pour que les membres de l'infobrol puissent effectuer des traductions en français des différents documents. Ceci devrait permettre aux débutants en programmation Java de consulter les API en français s'ils maîtrisent moins bien la langue de Shakespeare. Dans le cas où une traduction a été soumise, elle est disponible au moyen d'un lien en bas de page. Si la traduction a été validée, la page s'affiche par défaut en français, et un lien en bas de page permet d'atteindre la version en anglais.
Le code sur l'infobrol est automatiquement coloré selon la syntaxe, et les différents mots clés sont transformés en liens pour accéder rapidement aux informations.
Vous avez la possibilité de partager vos expériences en proposant vos propres extraits de code en utilisant le bouton "ajouter un commentaire" en bas de page. Si vous visitez simplement l'infobrol, vous avez déjà accès à cette fonction, mais si vous étes membre du brol, vous pouvez en plus utiliser des boutons supplémentaires de mise en forme, dont la coloration automatique de vos extraits de codes.
Vous pouvez modifier vos préférences dans votre profil pour ne plus afficher les interactions avec les réseaux sociaux sur ces pages.
8 mots clés dont 0 définis manuellement (plus d'information...).
Avertissement
Cette page ne possède pas encore de mots clés manuels, ceci est donc un exemple automatique (les niveaux de pertinence sont fictifs, mais les liens sont valables). Pour tester le nuage avec une page qui contient des mots définis manuellement, vous pouvez cliquer ici.Vous pouvez modifier vos préférences dans votre profil pour ne plus afficher le nuage de mots clés.
Recherche (afficher)
Utilisateur (masquer)
Navigation (masquer)
Apparence (afficher)
Stats (afficher)
Citation (masquer)