net.yudichev.jiotty.common.lang.Locks Maven / Gradle / Ivy
package net.yudichev.jiotty.common.lang;
import java.util.concurrent.locks.Lock;
import java.util.function.Supplier;
public final class Locks {
private Locks() {
}
public static void inLock(Lock lock, Runnable task) {
lock.lock();
try {
task.run();
} finally {
lock.unlock();
}
}
public static T inLock(Lock lock, Supplier supplier) {
lock.lock();
try {
return supplier.get();
} finally {
lock.unlock();
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy