为什么 Google GuavaStriped
类不包含以Supplier<Lock>
( Supplier<Semaphore>
, Supplier<ReadWriteLock>
) intsance 为参数的工厂方法?
例如,我想使用 CycleDetectingLockFactory 创建锁,但我不能:
final CycleDetectingLockFactory lockFactory = CycleDetectingLockFactory.newInstance( CycleDetectingLockFactory.Policies.THROW );
//...
Striped<Lock> cycleDetectingLocks = Striped.lazyWeakLock( 64, new Supplier<Lock>()
{
public Lock get()
{
return lockFactory.newReentrantLock( "" );
}
}; );