1

I have a doubt that when a thread A starts its operation on int q=1 and meanwhile the thread B starts operation on q

Both of them create a copy of the main memory in the local cache but when will the data are reflected back to main memory and get updated (not using volatile keyword) and using volatile keyword what is happening Can anyone please explain?

David Coler
  • 453
  • 3
  • 8
  • 1
    This question has a good answer that explains how `volatile` works: [Difference between volatile and synchronized in Java](https://stackoverflow.com/questions/3519664/difference-between-volatile-and-synchronized-in-java) – Jesper Oct 12 '18 at 14:05
  • You should eleborete your question body and title. Title doesn't give a clue about thread memory usege or volative keyword, etc. – ahmettolga Oct 12 '18 at 14:15

0 Answers0