equal
deleted
inserted
replaced
55 // setup to use Unsafe.compareAndSwapInt for updates |
55 // setup to use Unsafe.compareAndSwapInt for updates |
56 private static final Unsafe unsafe = Unsafe.getUnsafe(); |
56 private static final Unsafe unsafe = Unsafe.getUnsafe(); |
57 private static final long valueOffset; |
57 private static final long valueOffset; |
58 |
58 |
59 static { |
59 static { |
60 try { |
60 try { |
61 valueOffset = unsafe.objectFieldOffset |
61 valueOffset = unsafe.objectFieldOffset |
62 (AtomicInteger.class.getDeclaredField("value")); |
62 (AtomicInteger.class.getDeclaredField("value")); |
63 } catch (Exception ex) { throw new Error(ex); } |
63 } catch (Exception ex) { throw new Error(ex); } |
64 } |
64 } |
65 |
65 |
66 private volatile int value; |
66 private volatile int value; |
67 |
67 |
68 /** |
68 /** |
245 return Integer.toString(get()); |
245 return Integer.toString(get()); |
246 } |
246 } |
247 |
247 |
248 |
248 |
249 /** |
249 /** |
250 * Returns the value of this {@code AtomicInteger} as an |
250 * Returns the value of this {@code AtomicInteger} as an {@code int}. |
251 * {@code int}. |
|
252 */ |
251 */ |
253 public int intValue() { |
252 public int intValue() { |
254 return get(); |
253 return get(); |
255 } |
254 } |
256 |
255 |