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.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
/** /**
* @author neil * @author neil
@ -338,17 +341,10 @@ public class InformationCollector implements XMLReadable, XMLWriter {
return; return;
} }
Thread sendThread = new Thread(new Runnable() { ScheduledExecutorService service = Executors.newSingleThreadScheduledExecutor();
service.schedule(new Runnable() {
@Override @Override
public void run() { 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 currentTime = new Date().getTime();
long lastTime = getLastTimeMillis(); long lastTime = getLastTimeMillis();
if (currentTime - lastTime > DELTA) { if (currentTime - lastTime > DELTA) {
@ -359,8 +355,8 @@ public class InformationCollector implements XMLReadable, XMLWriter {
TemplateInfoCollector.getInstance().sendTemplateInfo(); TemplateInfoCollector.getInstance().sendTemplateInfo();
ErrorInfoUploader.getInstance().sendErrorInfo(); ErrorInfoUploader.getInstance().sendErrorInfo();
} }
}); }, SEND_DELAY, TimeUnit.SECONDS);
sendThread.start();
} }
/** /**

Loading…
Cancel
Save