Java >> Multithread >> Strategy
https://stackoverflow.com/questions/28834489/which-is-the-difference-between-atomicreference-and-synchronized/28837950#28837950 Prefer immutability whenever possible. For code that can't be immutable, try to confine mutation to a thread. If only one thing has to change across threads, use the atomic approach. If multiple changes across threads need to occur together undisturbed by other threads, use locking.