parallele-programmierung/u06-4/README.md

737 B

Problem 6.4: Implement AtomicXXX.updateAndGet

On slide 4-46 two implementations for the modification of an AtomicXXX object were presented: A loop with a compareAndSet() operation and the more abstract and more general updateAndGet() operation. Implement your own updateAndGet() method for the AtomicCounter class on slide 4-46. Use compareAndSet() for this. Use the following interface as the parameter type for the lambda expression:

interface IntUnaryOperator {
	int applyAsInt(int x);
}

What condition must hold for the behavior of the code passed to updateAndGet()?

Test your class with the class AtomicCounterTest to be found in the source code folder on he server. Its output must be 100000000.