清单1显示了如何使用锁定(同步)实现该类的例子。
Listing 1 shows an example of how this class might be implemented using locks (synchronization).
如果同步时还发生锁定争用,那么性能上付出的代价会大得多,因为会需要几个线程切换和系统调用。
If the synchronization actually requires contending for the lock, the performance penalty is substantially greater, as there will be several thread switches and system calls required.
因此不需要实现复杂的锁定及同步算法。
Thus, there is no need to implement complicated locking and synchronization algorithms.
应用推荐