Volatile Variable in java
Volatile variable is more useful in java. Now a days we using multithread in many
Java projects. During this we can use the volatile keyword.
Best scenario for using volatile variable:
In multiple thread concept may be single instance can be used by multiple thread .That time the volatile variable will be use for programmer...Because without volatile variable means if one thread will be changed by user it will affect by other threads also.
During this time we can mention master copy variable we mention as volatile variable..because of this other than master variable will be update value it actually update in cache memory not in main memory variable memory
Declaring a volatile variable
Class exvolatile
{
volatile int val;
.....
}