volatile variable in java
/* Volatile variable means that the variable will be directly read from
and written to the computer's main memory and not to the CPU cache.
In Java it is done using the volatile keyword.
This is used in multithreaded applications. In multithreaded environment
where each thread may copy the variable into caches of different cores.
Thus making the data available to other threads inconsistent.
*/
public class SharedObject
{
public volatile int counter = 0;
}