Commit b8b78355 authored by yanzg's avatar yanzg

修复等待时间

parent 69ff1127
...@@ -194,18 +194,24 @@ public class BeanDao { ...@@ -194,18 +194,24 @@ public class BeanDao {
private void timeOut(Class<?> cls, String name, String message, Runnable runnable) { private void timeOut(Class<?> cls, String name, String message, Runnable runnable) {
final Ref<Boolean> isRun = new Ref<>(false); final Ref<Boolean> isRun = new Ref<>(false);
ThreadHelper.runThread(() -> { ThreadHelper.runThread(() -> {
long timeMax = 1000; try {
int timeUnit = 10; long timeMax = 1000;
long start = System.currentTimeMillis(); int timeUnit = 10;
do { long start = System.currentTimeMillis();
ThreadHelper.sleep(timeUnit); do {
long end = System.currentTimeMillis(); ThreadHelper.sleep(timeUnit);
if (end - start > timeMax) { long end = System.currentTimeMillis();
timeUnit = 1000; if (end - start > timeMax) {
Log.error(cls, message + name + "超时,正在等待执行完成"); timeUnit = 1000;
Log.error(cls, message + name + "超时,正在等待执行完成");
}
} }
while (!isRun.value);
} catch (Exception ex) {
ex.printStackTrace();
} finally {
Log.info(cls, message + name + "完成");
} }
while (!isRun.value);
}); });
runnable.run(); runnable.run();
isRun.value = true; isRun.value = 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