What is Volatile

  • Every read and write on a volatile variable will be made directly to the  computer memory and not into CPU cache unlike instance variables
  • Value is same across all threads as they read directly from the Main memory
  • Add lot of performance overhead as the CRUD is done against the main memory
  • Object or primitives can be declared volatile
  • It can store null value
  • It never holds a lock and hence it cannot be used in a read-write-update atomic operations
  • Value of the variable is never cached thread locally 

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

Cheat Sheet To JAVA Latest Technology

%d bloggers like this: