另一方面,如果锁被占有很长时间,那么自旋的线程只会消耗CPU而不做任何有用的工作,因此带来浪费。
On the other hand, if the lock is held for a longer time, spinning is wasteful as the spinning thread consumes CPU without doing anything useful.
如果在超时期间无法获得锁,则向调用方返回null。
If the lock cannot be obtained in the timeout period, null is returned to the caller.
它较悲观会话锁更弱一些,相关方约定发出警告,而不是阻止。
This is weaker than a pessimistic session lock -- the convention adhered to by the participants is to warn, not to block.
应用推荐