有没有办法让threadPoolExecutor
监视线程并在达到超时阈值时重新生成它?
例如
ThreadPoolExecutor myThreadPool = new ThreadPoolExecutor(1, 1,
10L, TimeUnit.MILLISECONDS,
new LinkedBlockingQueue<Runnable>(1000));
myThreadPool.submit(new MyTask());
public MyTask() {
}
@Override
public void run() {
try {
// do something, this sometimes hangs, how do thread communicate to myThreadPool that it needs to be respawn?
} catch (Exception e) {
}