Is it correct to say that static
means one copy of the value for all objects and volatile
means one copy of the value for all threads?
Anyway a static
variable value is also going to be one value for all threads, then why should we go for volatile
?
I think
static
andvolatile
have no relation at all. I suggest you read java tutorial to understand Atomic Access, and why use atomic access, understand what is interleaved, you will find answer.