Java篇.自定义拒绝策略【ThreadPoolExecutor】

// 代码
public static class MyIgnorePolicy implements RejectedExecutionHandler {
       public void rejectedExecution(Runnable r, ThreadPoolExecutor e) {
           doLog(r, e);
       }
       private void doLog(Runnable r, ThreadPoolExecutor e) {
           // 可做日志记录等
           System.err.println( r.toString() + " rejected");
       }
   }

你可能感兴趣的:(Java)