1.synchronized & asynchronized

To share final variable in multiple threads, must use synchronized or volatile.

2. mutual exclusion or visibility
mutual exclusion: only one thread can hold a lock at a time.
visibility: make sure the later thread can see the former thread changes to data.

Atom operation might not be thread safe.
thread can save duplicates of variable in itself memory.

Leave a Reply