view src/goodjava/lucene/logging/SemaphoreLock.java @ 2091:ee7e711a91f2 ssltesting

fix inconsistent usage of DOMAIN/.well-known/acme-challenge and DOMAIN/acme-challenge
author Violet7
date Thu, 11 Dec 2025 20:33:51 -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);
	}
}