Java 删除传递给newsinglethreadpoolexecutor的所有任务

Java 删除传递给newsinglethreadpoolexecutor的所有任务,java,android,Java,Android,我想删除已传递给newSingleThreadPoolExecutor队列的所有任务,但创建单个线程池执行器不需要在构造函数中传递任何阻塞队列,因此我无法清除已传递给执行器的任务。另外,我不想调用executorService.shutdown() 或者executorService.ShutdownNow(),因为我想重用同一个executorService来运行新任务,而调用shutdown方法会使executor不可重用。因为当我在调用shutdown方法后传递任务时,我会得到一个异常 我

我想删除已传递给newSingleThreadPoolExecutor队列的所有任务,但创建单个线程池执行器不需要在构造函数中传递任何阻塞队列,因此我无法清除已传递给执行器的任务。另外,我不想调用executorService.shutdown() 或者executorService.ShutdownNow(),因为我想重用同一个executorService来运行新任务,而调用shutdown方法会使executor不可重用。因为当我在调用shutdown方法后传递任务时,我会得到一个异常

我认为这个答案最适合我的用例

但这不会从队列中删除当前任务,因此如何从队列中清除包括当前任务在内的所有任务