Recently I was reading a tutorial, in that I came across a statement that says..
\"The Java language specification guarantees that reading or writing a variable is
I think what it means is that long and double - read operation is atomic and write operation is atomic. But a read + write is not atomic.
volatile long num;
num = num+1
The above is not thread safe. There read and write are two separate operations. Each of those are guaranteed to be atomic, but the whole expression is not.
To make it thread safe you would need to use an AtomicLong and use the getAndIncrement function.