Commit 3ff11aca authored by yanzg's avatar yanzg

表结构修改

parent 23e6cee5
......@@ -53,7 +53,7 @@ public class CacheLock<T, M> implements Runnable {
/**
* 最长等待次数
*/
private int maxWaitCount = 30;
private int maxWaitSecond;
/**
* 构造函数
......@@ -108,12 +108,12 @@ public class CacheLock<T, M> implements Runnable {
return waitCount;
}
public int getMaxWaitCount() {
return maxWaitCount;
public int getMaxWaitSecond() {
return maxWaitSecond;
}
public void setMaxWaitCount(int maxWaitCount) {
this.maxWaitCount = maxWaitCount;
public void setMaxWaitSecond(int maxWaitSecond) {
this.maxWaitSecond = maxWaitSecond;
}
/**
......@@ -134,6 +134,7 @@ public class CacheLock<T, M> implements Runnable {
if (this.func == null) {
return;
}
long start = System.currentTimeMillis();
// 需要运行的函数
do {
// 开启唯一性锁,防止多人运行同一关键字的函数
......@@ -143,7 +144,9 @@ public class CacheLock<T, M> implements Runnable {
this.waitCount++;
ThreadHelper.sleep(waitUnitTime);
}
if (this.waitCount >= this.maxWaitCount) {
long end = System.currentTimeMillis();
long time = (end - start) / 1000;
if (this.maxWaitSecond > 0 && time >= this.maxWaitSecond) {
cache.remove(key);
throw new RuntimeCodeException("等待执行超时");
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment