What is syncronization in java?
Synchronization in Java is very expensive (in terms of time), and can easily become a performance bottleneck, however it is sometimes possible to overcome such performance loss simply moving superfluous synchronization to another place. In a situation where a data structure is being iterated over continually but rarely changed, it would be far slower to synchronize MyDataStructure.getData() resulting in continual, largely unnecessary locking/unlocking, than it would be simply to synchronize the add-/remove element methods.