What the right way to interrupt executor's thread? I've got this: Thread class with name Worker with method:
public void run() {
while(!(Thread.currentThread().isInterrupted()){
System.out.println("work " + Thread.currentThread().getName() + ":" + Thread.currentThread().isInterrupted());
}
}
And main class with:
ExecutorService executorService = Executors.newFixedThreadPool(threadCount);
Worker worker = new Worker();
executorService.execute(worker);
I try to call worker.interrupt();
or executorService.shutdownNow();
but my thread goes on and isInterrupted() is false.