실행자의 스레드를 방해하는 올바른 방법은 무엇입니까? 와실행자 스레드를 인터럽트하는 방법
public void run() {
while(!(Thread.currentThread().isInterrupted()){
System.out.println("work " + Thread.currentThread().getName() + ":" + Thread.currentThread().isInterrupted());
}
}
그리고 메인 클래스 : : 방법 이름 작업자 Thread 클래스 : 나는이있어
ExecutorService executorService = Executors.newFixedThreadPool(threadCount);
Worker worker = new Worker();
executorService.execute(worker);
내가 worker.interrupt();
또는 executorService.shutdownNow();
전화를 시도를하지만 내 스레드에와 isInterrupted (간다)가 거짓입니다.
확인이 밖으로있는 가능한 복제본 일 수 있습니다. http://stackoverflow.com/questions/7142665/why-does-thread-isinterrupted-always-return-false – GETah