Commit 862f0283 authored by yanzg's avatar yanzg

修改实例化关系

parent f92e96f4
...@@ -127,7 +127,7 @@ public class CacheLock implements Runnable { ...@@ -127,7 +127,7 @@ public class CacheLock implements Runnable {
}; };
do { do {
// 开启唯一性锁,防止多人运行同一关键字的函数 // 开启唯一性锁,防止多人运行同一关键字的函数
cache.tryLockAndRun(key, lockTime, TimeUnit.SECONDS, runnable); cache.tryLockAndRun(key, lockTime, TimeUnit.MILLISECONDS, runnable);
// 假如没有运行,则等待50毫秒后继续运行 // 假如没有运行,则等待50毫秒后继续运行
if (!runFlag) { if (!runFlag) {
this.waitCount++; this.waitCount++;
...@@ -137,14 +137,19 @@ public class CacheLock implements Runnable { ...@@ -137,14 +137,19 @@ public class CacheLock implements Runnable {
} }
private void funcRun() { private void funcRun() {
try {
if (this.waitCount > 0 && this.funcWait != null) { if (this.waitCount > 0 && this.funcWait != null) {
funcWait.run(); funcWait.run();
} }
if (this.func != null) { if (this.func != null) {
func.run(); func.run();
} }
} catch (Exception ex) {
ex.printStackTrace();
} finally {
runFlag = true; runFlag = true;
} }
}
/** /**
* 开始执行,每个关键字会等待其他关键字执行完成后执行 * 开始执行,每个关键字会等待其他关键字执行完成后执行
......
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