I am trying to learn Volatile keyword in Multi Threading and I came across this statement:
Volatile is preferred in cases when one thread reads and writes a shared variable and other threads just read the same. Whereas if there are more than 2 threads performing read and write both on the shared variable then only volatile is not enough, you need to have synchronisation as well.
I am aware of the volatility concept and synchronisation, so can someone please provide an example relating to the above statement?