Commit 72a368a2 authored by yanzg's avatar yanzg

升级新版本

parent d4ae3360
......@@ -4,7 +4,7 @@ import com.yanzuoguang.util.log.Log;
import com.yanzuoguang.util.thread.ThreadHelper;
import java.util.Queue;
import java.util.concurrent.*;
import java.util.concurrent.ConcurrentLinkedQueue;
import java.util.function.Consumer;
/**
......@@ -16,8 +16,7 @@ public class YzgTimeout {
public static final int TIME_OUT_DEFAULT = 15 * 1000;
public static final int TIME_OUT_TIP = 10 * 1000;
private static ExecutorService executorService;
private static final Queue<TimeInfo> queueInfos = new ConcurrentLinkedQueue<>();
private static Queue<TimeInfo> queueInfos = null;
/**
......@@ -85,18 +84,16 @@ public class YzgTimeout {
}
private static void init() {
if (executorService != null) {
if (queueInfos != null) {
return;
}
synchronized (YzgTimeout.class) {
if (executorService != null) {
if (queueInfos != null) {
return;
}
executorService = new ThreadPoolExecutor(1, 10, 1000,
TimeUnit.MILLISECONDS, new ArrayBlockingQueue<>(10));
queueInfos = new ConcurrentLinkedQueue<>();
ThreadHelper.runThread(() -> {
while (true) {
try {
......@@ -128,7 +125,7 @@ public class YzgTimeout {
if (time > poll.getTimeMax()) {
try {
poll.setTimeMax(poll.getTimeMax() + poll.getTimeOutTip());
executorService.execute(() -> poll.getHeart().heart(time));
ThreadHelper.runThread(() -> poll.getHeart().heart(time));
} catch (Exception ex) {
ex.printStackTrace();
}
......
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