com.soento.core.lang.DistributedLock Maven / Gradle / Ivy
package com.soento.core.lang;
/**
* 分布式锁
*
* @author soento
*/
public abstract class DistributedLock {
protected static final String LOCK_PREFIX = "LOCK_";
/**
* 锁的键值
*/
protected String lockKey;
/**
* 是否被锁定
*/
protected volatile boolean locked = false;
public String getLockKey() {
return this.lockKey;
}
/**
* 捕获锁
*
* @return true:成功获取, false:获取锁超时
*/
public abstract boolean acquire();
/**
* 释放锁
*/
public abstract void release();
}