src/share/classes/java/util/concurrent/atomic/AtomicInteger.java

Print this page




 229      * @return the updated value
 230      */
 231     public final int addAndGet(int delta) {
 232         for (;;) {
 233             int current = get();
 234             int next = current + delta;
 235             if (compareAndSet(current, next))
 236                 return next;
 237         }
 238     }
 239 
 240     /**
 241      * Returns the String representation of the current value.
 242      * @return the String representation of the current value.
 243      */
 244     public String toString() {
 245         return Integer.toString(get());
 246     }
 247 
 248 




 249     public int intValue() {
 250         return get();
 251     }
 252 





 253     public long longValue() {
 254         return (long)get();
 255     }
 256 





 257     public float floatValue() {
 258         return (float)get();
 259     }
 260 





 261     public double doubleValue() {
 262         return (double)get();
 263     }
 264 
 265 }


 229      * @return the updated value
 230      */
 231     public final int addAndGet(int delta) {
 232         for (;;) {
 233             int current = get();
 234             int next = current + delta;
 235             if (compareAndSet(current, next))
 236                 return next;
 237         }
 238     }
 239 
 240     /**
 241      * Returns the String representation of the current value.
 242      * @return the String representation of the current value.
 243      */
 244     public String toString() {
 245         return Integer.toString(get());
 246     }
 247 
 248 
 249     /**
 250      * Returns the value of this {@code AtomicInteger} as an
 251      * {@code int}.
 252      */
 253     public int intValue() {
 254         return get();
 255     }
 256 
 257     /**
 258      * Returns the value of this {@code AtomicInteger} as a {@code long}
 259      * after a widening primitive conversion.
 260      * @jls 5.1.2 Widening Primitive Conversions
 261      */
 262     public long longValue() {
 263         return (long)get();
 264     }
 265 
 266     /**
 267      * Returns the value of this {@code AtomicInteger} as a {@code float}
 268      * after a widening primitive conversion.
 269      * @jls 5.1.2 Widening Primitive Conversions
 270      */
 271     public float floatValue() {
 272         return (float)get();
 273     }
 274 
 275     /**
 276      * Returns the value of this {@code AtomicInteger} as a {@code double}
 277      * after a widening primitive conversion.
 278      * @jls 5.1.2 Widening Primitive Conversions
 279      */
 280     public double doubleValue() {
 281         return (double)get();
 282     }
 283 
 284 }