As you can see from the header, If Timetime (timeout) timeout, the stream continues to work,
ExecutorService executor = Executors.newFixedThreadPool(n);
Callable<Object> task = new Callable<Object>() {
public Object call() {
}
}
Future<Object> future = executor.submit(task);
try {
Object result = future.get(5, TimeUnit.SECONDS);
} catch (TimeoutException ex) {
}
If a thread continues to run and is blocked due to some I / O, etc., then when the thread is empty it cannot be skipped a new task, which means that trheadpool is stuck because all threads in the pool are blocked, isn’t it ?
source
share