view src/goodjava/lucene/logging/SemaphoreLock.java @ 2154:03d4c892b436 nginx_sites_addon

include nginx_sites ssl files; use absolute paths in Https.luan:nginx_ssl_conf()
author Violet7
date Tue, 27 Jan 2026 18:54:59 -0800
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);
	}
}