The only reason I can think of is because the person who wrote this code realized that only the array is volatile, but not its contents, and added a = a to ensure that the records executed on the elements of the array are visible.
It seems nothing changes when I take it out.
The fact that it is still running on your machine with your JVM does not mean that it will work on another machine with a different JVM. Theoretically, deleting the operator a = a; can lead to an infinite while loop.
Side note
I would think that the Java Memory Model (JMM) might allow the JVM to ignore this statement, just as synchronized(new Object()) could be ignored.
It seems that this is not the case * :
You may have noticed that I provided a way to get the volatile record above using only arrays: by writing out self-promotion .
* Jeremy Manson is one of the authors of JMM.
source share