Java AtomicLong compareAndSet() MethodThe compareAndSet() method of java AtomicLong class compares the current value of the AtomicLong instance to an expected value and if the two values are equal, it sets a new value for the AtomicLong instance. SyntaxParametersexpectedValue - The expected value newValue - The new value Example 1Test it NowOutput: 111 Example 2Test it NowOutput: 222 Example 3Test it NowOutput: -1 Example 4Test it NowOutput: -10 Next TopicJava AtomicLong |
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