What happens when a thread updates a `volatile` variable?
When a thread updates a `volatile` variable, the new value is immediately written to the main memory, and all other threads will see the updated value as soon as they access it.
Exactly! The value of the `volatile` variable is immediately visible to all threads after itâ€™s written.
Can you explain how this behavior prevents certain types of concurrency issues, such as stale data?