Override interrupt method for thread in threadpool
问题 Say I have this: class Queue { private static ExecutorService executor = Executors.newFixedThreadPool(1); public void use(Runnable r){ Queue.executor.execute(r); } } my question is - how can I define the thread that's used in the pool, specifically would like to override the interrupt method on thread(s) in the pool: @Override public void interrupt() { synchronized(x){ isInterrupted = true; super.interrupt(); } } 回答1: Define how threads for the pool are created by specifying a ThreadFactory.