Answers ( 1 )

  1. Volatile variable can be define as a variable which always has the latest updated value it is not cached somewhere so if multiple threads are accessing the volatile variable then they will always see the latest updated value instead of their own copied value.

    Volatile variable value is read from main memory not from cache. 

    1. It can be used as an alternative way of achieving synchronization in Java.
    2. All threads will see the current updated value of the volatile variable after completing the write operation

    0 Comment Add Comment/ View

Leave an answer

Logged in as