Commit b8b78355 authored by yanzg's avatar yanzg

修复等待时间

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