Browse Source

换用ScheduledExecutorService schedule来延时发送

bugfix/10.0
alex.sung 6 years ago
parent
commit
80707918f6
  1. 18
      designer-realize/src/main/java/com/fr/design/mainframe/InformationCollector.java

18
designer-realize/src/main/java/com/fr/design/mainframe/InformationCollector.java

@ -54,6 +54,9 @@ import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
/**
* @author neil
@ -338,17 +341,10 @@ public class InformationCollector implements XMLReadable, XMLWriter {
return;
}
Thread sendThread = new Thread(new Runnable() {
ScheduledExecutorService service = Executors.newSingleThreadScheduledExecutor();
service.schedule(new Runnable() {
@Override
public void run() {
try {
//读取XML的5分钟后开始发请求连接服务器.
Thread.sleep(SEND_DELAY);
} catch (InterruptedException e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
}
long currentTime = new Date().getTime();
long lastTime = getLastTimeMillis();
if (currentTime - lastTime > DELTA) {
@ -359,8 +355,8 @@ public class InformationCollector implements XMLReadable, XMLWriter {
TemplateInfoCollector.getInstance().sendTemplateInfo();
ErrorInfoUploader.getInstance().sendErrorInfo();
}
});
sendThread.start();
}, SEND_DELAY, TimeUnit.SECONDS);
}
/**

Loading…
Cancel
Save