-
Notifications
You must be signed in to change notification settings - Fork 15
Expand file tree
/
Copy pathStopCommand.java
More file actions
31 lines (25 loc) · 971 Bytes
/
StopCommand.java
File metadata and controls
31 lines (25 loc) · 971 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
package com.chess.command;
import java.io.OutputStream;
import org.apache.log4j.Logger;
import com.chess.StartChessEngine;
import com.chess.config.ChessEngineConfig;
import com.chess.process.EngineProcess;
public class StopCommand implements Runnable {
private static final long LIMITTIME = Integer.valueOf(ChessEngineConfig.limitTime);// 引擎最多可以考虑的时间,超过就要马上返回下法。
private Logger log = Logger.getLogger(StopCommand.class);
@Override
public void run() {
long currentTimeMillis = System.currentTimeMillis();
if (StartChessEngine.requestTime != 0 && !StartChessEngine.hasReturn
&& currentTimeMillis - StartChessEngine.requestTime > LIMITTIME) {
try {
OutputStream outputStream = EngineProcess.getOutputStream();
outputStream.write("stop\r\n".getBytes());
outputStream.flush();
log.debug("stop");
} catch (Exception e) {
e.printStackTrace();
}
}
}
}