using volatile keyword
- by sap
As i understand, if we declare a variable as volatile, then it will not be stored in the local cache. Whenever thread are updating the values, it is updated to the main memory. So, other threads can access the updated value.
But in the following program both volatile and non-volatile variables are displaying same value.
The volatile variable is…