Java AtomicLong getAndSet() MethodThe getAndSet() method of Java AtomicLong class atomically sets the value to newValue and returns the old value SyntaxParametersnewValue - the new value Returnsthe previous value Example 1Test it NowOutput: Previous Value : 0 New Value : 10 Example 2Test it NowOutput: Previous Value : 5 New Value : 10 Example 3Test it NowOutput: Previous Value : -10 New Value : 20 Example 4Test it NowOutput: Previous Value : -5 New Value : -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