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

Print this page




 243      * @return the updated value
 244      */
 245     public final long addAndGet(long delta) {
 246         for (;;) {
 247             long current = get();
 248             long next = current + delta;
 249             if (compareAndSet(current, next))
 250                 return next;
 251         }
 252     }
 253 
 254     /**
 255      * Returns the String representation of the current value.
 256      * @return the String representation of the current value.
 257      */
 258     public String toString() {
 259         return Long.toString(get());
 260     }
 261 
 262 





 263     public int intValue() {
 264         return (int)get();
 265     }
 266 




 267     public long longValue() {
 268         return get();
 269     }
 270 





 271     public float floatValue() {
 272         return (float)get();
 273     }
 274 





 275     public double doubleValue() {
 276         return (double)get();
 277     }
 278 
 279 }


 243      * @return the updated value
 244      */
 245     public final long addAndGet(long delta) {
 246         for (;;) {
 247             long current = get();
 248             long next = current + delta;
 249             if (compareAndSet(current, next))
 250                 return next;
 251         }
 252     }
 253 
 254     /**
 255      * Returns the String representation of the current value.
 256      * @return the String representation of the current value.
 257      */
 258     public String toString() {
 259         return Long.toString(get());
 260     }
 261 
 262 
 263     /**
 264      * Returns the value of this {@code AtomicLong} as an {@code int}
 265      * after a narrowing primitive conversion.
 266      * @jls 5.1.3 Narrowing Primitive Conversions
 267      */
 268     public int intValue() {
 269         return (int)get();
 270     }
 271 
 272     /**
 273      * Returns the value of this {@code AtomicLong} as a {@code long}
 274      * value.
 275      */
 276     public long longValue() {
 277         return get();
 278     }
 279 
 280     /**
 281      * Returns the value of this {@code AtomicLong} as a {@code float}
 282      * after a widening primitive conversion.
 283      * @jls 5.1.2 Widening Primitive Conversions
 284      */
 285     public float floatValue() {
 286         return (float)get();
 287     }
 288 
 289     /**
 290      * Returns the value of this {@code AtomicLong} as a {@code
 291      * double} after a widening primitive conversion.
 292      * @jls 5.1.2 Widening Primitive Conversions
 293      */
 294     public double doubleValue() {
 295         return (double)get();
 296     }
 297 
 298 }