在我的Java程序中,我需要一个单许可证信号量对象,其中有一个额外的获取方法,如下所示:它的行为如下:如果之前没有遇到id,那么记住它,然后做java.util.concurrent.Semaphoreprivate final Set<Integer> favoured = new ConcurrentSkipListSet<Integer>();
return semaphore.t
Semaphore (这个类可以看作是一个Semaphore,只有1许可,不允许许可数量变为负数):acquire(long timeout, TimeUnit timeUnit)tryAcquire(long timeout, TimeUnit timeUnit)客户端代码中的使用模式: * @return null, or the combination for releasing the lock