The result type returned by this Future's {@code get} method
还有这样一个方法,根据此方法可以判断出任务是否完成,完成返回为true
/**
* Returns {@code true} if this task completed.
*
* Completion may be due to normal termination, an exception, or
* cancellation -- in all of these cases, this method will return
* {@code true}.
*
* @return {@code true} if this task completed
*/
boolean isDone();
如下
public String outBreakStatisTask() {
String s = "";
if (ExcuterService.excuterService.isShutdown()) {
//开启多线程
Future submit = ExcuterService.excuterService.submit(new OutstaticService());
if (submit.isDone()) {
try {
s = submit.get().toString();
} catch (Exception e) {
log.error("错误:[{}]",e.getMessage());
}
}
}
return s;
}