Synchronized
In the case of the resource competition is not very intense, occasionally there will be synchronization situations, synchronized is very appropriate. The reason is that the compiler usually optimizes synchronize as much as possible, and is also very readable, understandable by programmers who don't use more than 5 threads.
Reentrantlock:
Reentrantlock provides a variety of synchronization, such as time-limited synchronization, can be interrupt synchronization (synchronized synchronization is not interrupt) and so on. In the case of the resource competition is not intense, the performance is slightly more than synchronized. But when the synchronization is very intense, the performance of synchronized can fall dozens of times times. And Reentrantlock can still maintain the norm.
Atomic:
Similar to the above, in a less intense situation, performance is slightly worse than synchronized, and in times of intense, it can also maintain the norm. In intense times, the performance of atomic will be better than that of Reentrantlock. However, there is a disadvantage, is that only one value can be synchronized, a section of code can only appear a atomic variable, more than one synchronization is invalid. Because he can't sync between multiple atomic.
So, when we write synchronization, the priority is synchronized, if there is a special need, and then further optimization. Reentrantlock and atomic if not used well, not only can not improve performance, but also can bring disaster.
Performance comparisons of various synchronization methods (Synchronized,reentrantlock,atomic)