1. Volatile keyword
The Java language provides a slightly weaker synchronization mechanism, the volatile variable. Variables modified by the volatile keyword are not cached in registers or in places that are not visible to other processors, so the most recent value is always returned each time the Volatitle type variable is read, rather than being fetched from the register.
Since the locking mechanism ensures visibility and ensures atomicity, volatile can only ensure visibility.
2. Release and Escape
" Publish (Publish)" an object that enables an object to be used in code outside the current scope. If you save a reference to the object to a place that other code can access, either return the reference in a non-private method, or pass the reference to a method in another class.
This is called escaping (escape) when an object that should not be published is published.
Java Multithreading--volatile keywords, publishing, and escaping