Changed the code to use explicit Memory Barriers/Fences by using AtomicLong.