此方法在ScheduledThreadPoolExecutor中声明。
public void setRemoveonCancelPolicy(boolean value) { removeonCancel = value;}Executors类通过newScheduledThreadPool和类似方法返回此执行程序。
public static ScheduledExecutorService newScheduledThreadPool(int corePoolSize) { return new ScheduledThreadPoolExecutor(corePoolSize);}简而言之,您可以强制转换执行程序服务引用以调用该方法
ScheduledThreadPoolExecutor ex = (ScheduledThreadPoolExecutor) Executors.newScheduledThreadPool(5);ex.setRemoveonCancelPolicy(true);
或
new ScheduledThreadPoolExecutor自己创建。
ScheduledThreadPoolExecutor ex = new ScheduledThreadPoolExecutor(5);ex.setRemoveonCancelPolicy(true);



