Answer
The volatile keyword ensures visibility of changes to variables across threads.
Volatile variables are always read from and written to the main memory, preventing threads from caching them. This ensures that when one thread updates a volatile variable, the change is visible to other threads. For example, a volatile boolean flag can be used to safely terminate a thread.