Originally Posted by sagarbirari
|
|
If you want performance then used synchronized block
|
This is way to general. And perhaps misleading. There is no difference between using a synchronized block and using synchronization on an object with the same scope as the block. The compiler just does the same thing as you would manually.
If you want to get performance and scaling, you have to carefully decide what needs synchronization and what types of locking it needs. The key is to obtain the fewest locks and locks of the weakest strength practical, for the shortest time.
Look at things like java.util.concurrent.locks.ReentrantReadWriteLock