参考:
https://blog.csdn.net/u012168222/article/details/52790400
https://www.cnblogs.com/stonefeng/p/5967451.html
//获取CPU数量
static int processors = Runtime.getRuntime().availableProcessors();
//使用线程池对学生人脸建模
static ExecutorService fixedThreadPool = Executors.newFixedThreadPool(processors + 1);
for (::) {//根据实际情况填写
fixedThreadPool.execute(new Runnable() {
@Override
public void run() {
//具体操作
}
});
}
fixedThreadPool.shutdown();
boolean isFlag=true;
while (isFlag){
if (fixedThreadPool.isTerminated()){
//具体操作
isFlag=false;
}else{
//具体操作
}
}