What does the `volatile` keyword do in the context of the Java Memory Model?
The `volatile` keyword makes sure that all variables are updated in the main memory and not stored in the CPU cache.
Thatâ€™s incorrect. The `volatile` keyword ensures visibility, but it doesn't necessarily prevent caching; it's about ensuring threads see the most up-to-date value in main memory.
Can you explain how the Java Memory Model handles caching and visibility of variables in multithreaded environments?