I have several processes (on the same computer) which together need to sequentially access the elements of an array in shared memory. To do this I want to store the current index into the array as an int in shared memory, and for each of the processes to be able to get the current value of the index and increment it by a fixed value in one single atomic operation. How can I do this in Java?
Note: I only want this atomic operation coded in Java. The rest of the code happens to be in MATLAB.