Commit 72a368a2 authored by yanzg's avatar yanzg

升级新版本

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