In this example, you implemented two different tasks to work with an AtomicIntegerArray object:
- Incrementer: This class increments all the elements of the array using the getAndIncrement() method
- Decrementer: This class decrements all the elements of the array using the getAndDecrement() method
In the Main class, you created AtomicIntegerArray with 1,000 elements, then you executed 100 incrementer and 100 decrementer tasks. At the end of these tasks, if there were no inconsistency errors, all the elements of the array must have the value 0. If you execute the program, you will see how the program only writes the final message to the console because all the elements are zero.