Commit 3ff11aca authored by yanzg's avatar yanzg

表结构修改

parent 23e6cee5
...@@ -53,7 +53,7 @@ public class CacheLock<T, M> implements Runnable { ...@@ -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 { ...@@ -108,12 +108,12 @@ public class CacheLock<T, M> implements Runnable {
return waitCount; return waitCount;
} }
public int getMaxWaitCount() { public int getMaxWaitSecond() {
return maxWaitCount; return maxWaitSecond;
} }
public void setMaxWaitCount(int maxWaitCount) { public void setMaxWaitSecond(int maxWaitSecond) {
this.maxWaitCount = maxWaitCount; this.maxWaitSecond = maxWaitSecond;
} }
/** /**
...@@ -134,6 +134,7 @@ public class CacheLock<T, M> implements Runnable { ...@@ -134,6 +134,7 @@ public class CacheLock<T, M> implements Runnable {
if (this.func == null) { if (this.func == null) {
return; return;
} }
long start = System.currentTimeMillis();
// 需要运行的函数 // 需要运行的函数
do { do {
// 开启唯一性锁,防止多人运行同一关键字的函数 // 开启唯一性锁,防止多人运行同一关键字的函数
...@@ -143,7 +144,9 @@ public class CacheLock<T, M> implements Runnable { ...@@ -143,7 +144,9 @@ public class CacheLock<T, M> implements Runnable {
this.waitCount++; this.waitCount++;
ThreadHelper.sleep(waitUnitTime); 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); cache.remove(key);
throw new RuntimeCodeException("等待执行超时"); 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