Java AtomicLong weakCompareAndSet() MethodThe weakCompareAndSet() method of java AtomicLong class atomically sets the value to the given updated value if the current value is equal to the expected value. May fail spuriously and does not provide ordering guarantees, so is only rarely an appropriate alternative to compareAndSet. SyntaxParametersexpectedValue - the expected value newValue - the new value Returnstrue if successful Example 1Test it NowOutput: 111 Example 2Test it NowOutput: 0 Example 3Test it NowOutput: -45 Example 4Test it NowOutput: -10 Next TopicJava AtomicLong Class |
We provides tutorials and interview questions of all technology like java tutorial, android, java frameworks
G-13, 2nd Floor, Sec-3, Noida, UP, 201301, India