Mercurial Hosting > luan
view src/goodjava/lucene/logging/SemaphoreLock.java @ 1602:55d7b60c074d
add DirHandler to WebHandler
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Fri, 09 Apr 2021 23:46:12 -0600 |
parents | 634f6765830e |
children |
line wrap: on
line source
package goodjava.lucene.logging; import java.util.concurrent.Semaphore; import java.util.concurrent.TimeUnit; public final class SemaphoreLock { private final Semaphore semaphore = new Semaphore(1); public void unlock() { semaphore.release(); } public boolean isLocked() { return semaphore.availablePermits() == 0; } public boolean tryLock(long time,TimeUnit unit) throws InterruptedException { return semaphore.tryAcquire(time,unit); } }