Java AtomicInteger weakCompareAndSet() methodThe weakCompareAndSet() method of Java AtomicInteger class atomically sets the value to the new value if current value is equal to the expected value. SyntaxParametersThis method will take the two arguments one is expected value and other one is new value. ReturnIt will return the new value if the current value and the expected value are equal. Example 1Test it NowOutput: the new value is: 100 Example 2Test it NowOutput: the new value is: 1 Example 3Test it NowOutput: the new value is: 10 Example 4Test it NowOutput: the new value is: 1 Example 5Test it NowOutput: the new value is: -100 Next TopicJava AtomicInteger |
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