@Test public void testSimpleExecution() { Executor executor = new DefaultThreadPoolExecutor(1, 1, Integer.MAX_VALUE, TimeUnit.SECONDS, new SynchronousQueue()); final CountDownLatch continueSignal = new CountDownLatch(1); executor.execute(new Runnable(){ public void run() { continueSignal.countDown(); } }); try { boolean success = continueSignal.await(2, TimeUnit.SECONDS); if (!success) { Assert.fail("Test timed out waiting for execution to complete."); } } catch (InterruptedException e) { Assert.fail("Test was interrupted: " + e); } DefaultThreadPoolExecutor tpe = (DefaultThreadPoolExecutor)executor; tpe.shutdown(); }
public void execute(Runnable command) { try { super.execute(command); } catch (RejectedExecutionException e) { FailedExecutionHandler handler = getFailedExecutionHandler(); if (handler != null) { handler.failedExecution(command, this, e); } else if (Log.isError()) { Log.getLogger(LogCategories.EXECUTOR).error("DefaultThreadPoolExecutor hit a RejectedExecutionException but no FailedExecutionHandler is registered to handle the error.", e); } } }
DefaultThreadPoolExecutor extends ThreadPoolExecutor implements Executor { public void execute(Runnable command) { try { super.execute(command); } catch (RejectedExecutionException e) { FailedExecutionHandler handler = getFailedExecutionHandler(); if (handler != null) { handler.failedExecution(command, this, e); } else if (Log.isError()) { Log.getLogger(LogCategories.EXECUTOR).error("DefaultThreadPoolExecutor hit a RejectedExecutionException but no FailedExecutionHandler is registered to handle the error.", e); } } } }
DefaultThreadPoolExecutor extends ThreadPoolExecutor implements Executor { public void execute(Runnable command) { try { super.execute(command); } catch (RejectedExecutionException e) { FailedExecutionHandler handler = getFailedExecutionHandler(); if (handler != null) { handler.failedExecution(command, this, e); } else if (Log.isError()) { Log.getLogger(LogCategories.EXECUTOR).error("DefaultThreadPoolExecutor hit a RejectedExecutionException but no FailedExecutionHandler is registered to handle the error.", e); } } } DefaultThreadPoolExecutor();  DefaultThreadPoolExecutor(int corePoolSize, int maximumPoolSize, long keepAliveTime, TimeUnit unit, BlockingQueue workQueue);  DefaultThreadPoolExecutor(int corePoolSize, int maximumPoolSize, long keepAliveTime, TimeUnit unit, BlockingQueue workQueue, RejectedExecutionHandler handler);  DefaultThreadPoolExecutor(int corePoolSize, int maximumPoolSize, long keepAliveTime, TimeUnit unit, BlockingQueue workQueue, ThreadFactory threadFactory);  DefaultThreadPoolExecutor(int corePoolSize, int maximumPoolSize, long keepAliveTime, TimeUnit unit, BlockingQueue workQueue, ThreadFactory threadFactory, RejectedExecutionHandler handler); }
DefaultThreadPoolExecutor extends ThreadPoolExecutor implements Executor { public void execute(Runnable command) { try { super.execute(command); } catch (RejectedExecutionException e) { FailedExecutionHandler handler = getFailedExecutionHandler(); if (handler != null) { handler.failedExecution(command, this, e); } else if (Log.isError()) { Log.getLogger(LogCategories.EXECUTOR).error("DefaultThreadPoolExecutor hit a RejectedExecutionException but no FailedExecutionHandler is registered to handle the error.", e); } } } DefaultThreadPoolExecutor();  DefaultThreadPoolExecutor(int corePoolSize, int maximumPoolSize, long keepAliveTime, TimeUnit unit, BlockingQueue workQueue);  DefaultThreadPoolExecutor(int corePoolSize, int maximumPoolSize, long keepAliveTime, TimeUnit unit, BlockingQueue workQueue, RejectedExecutionHandler handler);  DefaultThreadPoolExecutor(int corePoolSize, int maximumPoolSize, long keepAliveTime, TimeUnit unit, BlockingQueue workQueue, ThreadFactory threadFactory);  DefaultThreadPoolExecutor(int corePoolSize, int maximumPoolSize, long keepAliveTime, TimeUnit unit, BlockingQueue workQueue, ThreadFactory threadFactory, RejectedExecutionHandler handler); FailedExecutionHandler getFailedExecutionHandler(); void setFailedExecutionHandler(FailedExecutionHandler value); void execute(Runnable command); }
DefaultThreadPoolExecutor extends ThreadPoolExecutor implements Executor { public void execute(Runnable command) { try { super.execute(command); } catch (RejectedExecutionException e) { FailedExecutionHandler handler = getFailedExecutionHandler(); if (handler != null) { handler.failedExecution(command, this, e); } else if (Log.isError()) { Log.getLogger(LogCategories.EXECUTOR).error("DefaultThreadPoolExecutor hit a RejectedExecutionException but no FailedExecutionHandler is registered to handle the error.", e); } } } DefaultThreadPoolExecutor();  DefaultThreadPoolExecutor(int corePoolSize, int maximumPoolSize, long keepAliveTime, TimeUnit unit, BlockingQueue workQueue);  DefaultThreadPoolExecutor(int corePoolSize, int maximumPoolSize, long keepAliveTime, TimeUnit unit, BlockingQueue workQueue, RejectedExecutionHandler handler);  DefaultThreadPoolExecutor(int corePoolSize, int maximumPoolSize, long keepAliveTime, TimeUnit unit, BlockingQueue workQueue, ThreadFactory threadFactory);  DefaultThreadPoolExecutor(int corePoolSize, int maximumPoolSize, long keepAliveTime, TimeUnit unit, BlockingQueue workQueue, ThreadFactory threadFactory, RejectedExecutionHandler handler); FailedExecutionHandler getFailedExecutionHandler(); void setFailedExecutionHandler(FailedExecutionHandler value); void execute(Runnable command);  }