Monday, 25 April 2016

volatile vs. transient keywords


volatile 
vs. transient
  • transient keyword is used with instance variables to exclude them from serialization process.
  • volatile keyword is used to indicate compiler and JVM that always read its value from main memory (keeping the volatile variable out of CPU caches)

  • transient keyword cannot be used with static keyword
  • volatile can be used with static keyword

No comments:

Post a Comment

Note: only a member of this blog may post a comment.