com.softicar.platform.common.core.thread.Locker Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of platform-common Show documentation
Show all versions of platform-common Show documentation
The SoftiCAR Platform is a lightweight, Java-based library to create interactive business web applications.
package com.softicar.platform.common.core.thread;
import java.util.concurrent.locks.Lock;
/**
* An {@link AutoCloseable} to lock a {@link Lock}.
*
* Use this in a try-with-resource.
*
* @author Oliver Richers
*/
public class Locker implements AutoCloseable {
private final Lock lock;
public Locker(Lock lock) {
this.lock = lock;
lock.lock();
}
@Override
public void close() {
lock.unlock();
}
}