Reprinted from Http://www.cnblogs.com/skywang12345/p/java_threads_category.html
JUC:java.util.concurrent
One, Juc Atom class
Depending on the type of data being modified, the atomic manipulation classes in the Juc package can be divided into 4 classes.
1. Basic type : Atomicinteger, Atomiclong, Atomicboolean;
2. array type : Atomicintegerarray, Atomiclongarray, Atomicreferencearray;
3. reference type : Atomicreference, Atomicstampedrerence, atomicmarkablereference;
4. object's property modification type : Atomicintegerfieldupdater, Atomiclongfieldupdater, Atomicreferencefieldupdater.
These classes exist to perform atomic operations on the corresponding data. The so-called atomic operation means that the operation process is not interrupted, and that the data operation is carried out in an atomic manner.
Atomiclong:
Atomiclong is a function of atomic manipulation of long-shaped shapes.
In 32-bit operating systems, the 64-bit long and double variables are not atomic because they are manipulated by the JVM as a two separated 32-bit. The use of Atomiclong allows long operations to remain atomic.
Example:
Packagecom.util.concurrent.atomic;ImportJava.util.concurrent.atomic.AtomicLong; Public classAtomiclongtest { Public Static voidMain (string[] args) {//TODO auto-generated Method StubAtomiclong Matolong=NewAtomiclong (); Matolong.set (0x0123456789abcdefl); System.out.println ("ToString ()" +matolong.tostring ()); System.out.println ("Get ()" +matolong.get ()); System.out.println ("Intvalue ()" +Matolong.intvalue ()); System.out.println ("Longvalue ()" +Matolong.longvalue ()); System.out.println ("Incrementandget ()" +matolong.incrementandget ()); System.out.println ("Getandincrement ()" +matolong.getandincrement ()); System.out.println ("Decrementandget ()" +matolong.decrementandget ()); System.out.println ("Getanddecrement ()" +matolong.getanddecrement ()); System.out.println ("Get ()" +matolong.get ()); System.out.println ("Addandget ()" + Matolong.addandget (0x10)); System.out.println ("Getandadd ()" + Matolong.getandadd (0x10)); System.out.println ("Getandset ()" + Matolong.getandset (0x0123456789abcdeel)); System.out.println ("Compareandset ()" + Matolong.compareandset (0x0123456789abcdeel, 0x0123456789abcdedl)); System.out.println ("Get ()" +matolong.get ()); }}
Results:
ToString () 81985529216486895get ()81985529216486895intvalue () -1985229329longvalue () 81985529216486895incrementandget ()81985529216486896getandincrement ()81985529216486896 Decrementandget ()81985529216486896getanddecrement () 81985529216486896get () 81985529216486895addandget ()81985529216486911getandadd () 81985529216486911getandset () 81985529216486927compareandset ()trueget ()81985529216486893
Java Advanced Feature Series--concurrent