jdk/src/share/classes/java/util/concurrent/atomic/AtomicInteger.java
changeset 11134 9ff7640994bf
parent 10067 1263ecd22db6
child 14325 622c473a21aa
equal deleted inserted replaced
11133:e05aee7c8611 11134:9ff7640994bf
    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