2
我使用的ExecutorService喜欢,爪哇 - ExecutorService的:如何重新运行 “等待状态” 线程
ExecutorService executorService = Executors.newFixedThreadPool(5);
for(int i = 0 ; i < 5 ; i ++){
executorService.submit(new MyRunnable());
}
和我的Runnable像,
@Override
public void run(){
while(true){
try{
Data data = SynchronizedQueue.getData(); // Class Name is Sample...
if(data != null){
//process with data
}else{
Thread.sleep(1);
}
}catch(Exception e){
e.printStackTrace();
}
}
}
当我从Runnable接口的while-打破循环,线程的状态改变为“等待”。
Q1。我的“while(true)loop”会死吗? Q2302。如果它能够死亡,如何重新运行?
谢谢。
编号VisualVM告诉我线程的状态是“等待”。 – bot
是否等于等于终止? – bot
我以为Executor.newFixedThreadPool保持线程 – bot