Java多线程系列--“JUC原子类”02之 AtomicLong原子类(二)
t()", mAtoLong.get());
13 System.out.printf("%20s : 0x%016X\n", "intValue()", mAtoLong.intValue());
14 System.out.printf("%20s : 0x%016X\n", "longValue()", mAtoLong.longValue());
15 System.out.printf("%20s : %s\n", "doubleva lue()", mAtoLong.doubleva lue());
16 System.out.printf("%20s : %s\n", "floatValue()", mAtoLong.floatValue());
17
18 System.out.printf("%20s : 0x%016X\n", "getAndDecrement()", mAtoLong.getAndDecrement());
19 System.out.printf("%20s : 0x%016X\n", "decrementAndGet()", mAtoLong.decrementAndGet());
20 System.out.printf("%20s : 0x%016X\n", "getAndIncrement()", mAtoLong.getAndIncrement());
21 System.out.printf("%20s : 0x%016X\n", "incrementAndGet()", mAtoLong.incrementAndGet());
22
23 System.out.printf("%20s : 0x%016X\n", "addAndGet(0x10)", mAtoLong.addAndGet(0x10));
24 System.out.printf("%20s : 0x%016X\n", "getAndAdd(0x10)", mAtoLong.getAndAdd(0x10));
25
26 System.out.printf("\n%20s : 0x%016X\n", "get()", mAtoLong.get());
27
28 System.out.printf("%20s : %s\n", "compareAndSet()", mAtoLong.compareAndSet(0x12345679L, 0xFEDCBA9876543210L));
29 System.out.printf("%20s : 0x%016X\n", "get()", mAtoLong.get());
30 }
31 }
复制代码
运行结果:
复制代码
get() : 0x0123456789ABCDEF
intValue() : 0x0000000089ABCDEF
longValue() : 0x0123456789ABCDEF
doubleva lue() : 8.1985529216486896E16
floatValue() : 8.1985531E16
getAndDecrement() : 0x0123456789ABCDEF
decrementAndGet() : 0x0123456789ABCDED
getAndIncrement() : 0x0123456789ABCDED
incrementAndGet() : 0x0123456789ABCDEF
addAndGet(0x10) : 0x0123456789ABCDFF
getAndAdd(0x10) : 0x0123456789ABCDFF
get() : 0x0123456789ABCE0F
compareAndSet() : false
get() : 0x0123456789ABCE0F