In Java volatile keyword is used to guarantee memory visibility of a variable. When a variable is marked as volatile, it will be stored in main memory. Every read & write is performed on main memory instead of CPU cache. In case of without volatile instance variable, read/write are always performed on CPU cache not directly on main memory, in such cases when multiple threads are performing read/write on multiprocessor system there are possibilities that

Read more 0