import java.util.concurrent.ThreadPoolExecutor; //导入方法依赖的package包/类
/**
* purge removes cancelled tasks from the queue
*/
public void testPurge() throws InterruptedException {
final CountDownLatch threadStarted = new CountDownLatch(1);
final CountDownLatch done = new CountDownLatch(1);
final BlockingQueue q = new ArrayBlockingQueue<>(10);
final ThreadPoolExecutor p =
new ThreadPoolExecutor(1, 1,
LONG_DELAY_MS, MILLISECONDS,
q);
try (PoolCleaner cleaner = cleaner(p, done)) {
FutureTask[] tasks = new FutureTask[5];
for (int i = 0; i < tasks.length; i++) {
Callable task = new CheckedCallable() {
public Boolean realCall() throws InterruptedException {
threadStarted.countDown();
await(done);
return Bo