Volatile in java

76 views

Published on

Objects that are declared as volatile are usually used to communicate state information among threads,To ensure CPU caches are updated, that is, kept in sync, in the presence of volatile fields, a CPU instruction, a memory barrier, often called a membar or fence, is emitted to update CPU caches with a change in a volatile field’s value.

The volatile modifier tells the compiler that the variable modified by volatile can be changed unexpectedly by other parts of your program.

The volatile variable must be used in Thread Context only.


http://www.youtube.com/watch?v=y8_jrkHEZpg&list=PLrUFyg1unBb9bhxd9ck0LEL89UB_G6-ZJ&index=5

Published in: Education
  • Be the first to comment

  • Be the first to like this

Volatile in java

  1. 1. Volatile in Java With Example
  2. 2. Fact Points • Objects that are declared as volatile are usually used to communicate state information among threads,To ensure CPU caches are updated, that is, kept in sync, in the presence of volatile fields, a CPU instruction, a memory barrier, often called a membar or fence, is emitted to update CPU caches with a change in a volatile field’s value. • The volatile modifier tells the compiler that the variable modified by volatile can be changed unexpectedly by other parts of your program. • The volatile variable must be used in Thread Context only.
  3. 3. Video Demo

×