Monday 16 January 2017

Volatile keyword in java

Each thread has its own stack, and so its own copy of variables it can access. When the thread is created, it copies the value of all accessible variables in its own memory. The volatile keyword is used to say to the JVM "Warning, this variable may be modified in another Thread". The volatile forces the thread to update the original variable for each variable.

No comments:

Post a Comment