If you have two operations that require synchronization separated by a small block of thread-safe code, you are generally better just using a single synchronized block.
要是您想用一小块线程安全代码把要求同步的两个操作隔开,那么只使用一个同步块一般会更好些。
2
In cases where synchronization is necessary, the synchronized code block should be minimized.
在有必要进行同步的场合下,应该尽量缩小同步代码块。
3
But if the hashes differ, the out-of-date block is marked as out of sync, and subsequent synchronization ensures that the block is properly synchronized.