Javadoc: ThreadPool doesn't reject while shutdown (#23678)

It caught me offguard yesterday that our executors won't always
reject when the ThreadPool is shutdown.
This commit is contained in:
Nik Everett 2017-06-21 12:21:48 -04:00 committed by GitHub
parent 926527adc3
commit bec1a49a54
1 changed files with 13 additions and 4 deletions

View File

@ -54,6 +54,7 @@ import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.concurrent.Executor; import java.util.concurrent.Executor;
import java.util.concurrent.ExecutorService; import java.util.concurrent.ExecutorService;
import java.util.concurrent.RejectedExecutionException;
import java.util.concurrent.RejectedExecutionHandler; import java.util.concurrent.RejectedExecutionHandler;
import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.ScheduledFuture; import java.util.concurrent.ScheduledFuture;
@ -298,16 +299,24 @@ public class ThreadPool extends AbstractComponent implements Closeable {
} }
/** /**
* Get the generic executor service. This executor service {@link Executor#execute(Runnable)} method will run the {@link Runnable} it * Get the generic {@link ExecutorService}. This executor service
* is given in the {@link ThreadContext} of the thread that queues it. * {@link Executor#execute(Runnable)} method will run the {@link Runnable} it is given in the
* {@link ThreadContext} of the thread that queues it.
* <p>
* Warning: this {@linkplain ExecutorService} will not throw {@link RejectedExecutionException}
* if you submit a task while it shutdown. It will instead silently queue it and not run it.
*/ */
public ExecutorService generic() { public ExecutorService generic() {
return executor(Names.GENERIC); return executor(Names.GENERIC);
} }
/** /**
* Get the executor service with the given name. This executor service's {@link Executor#execute(Runnable)} method will run the * Get the {@link ExecutorService} with the given name. This executor service's
* {@link Runnable} it is given in the {@link ThreadContext} of the thread that queues it. * {@link Executor#execute(Runnable)} method will run the {@link Runnable} it is given in the
* {@link ThreadContext} of the thread that queues it.
* <p>
* Warning: this {@linkplain ExecutorService} might not throw {@link RejectedExecutionException}
* if you submit a task while it shutdown. It will instead silently queue it and not run it.
* *
* @param name the name of the executor service to obtain * @param name the name of the executor service to obtain
* @throws IllegalArgumentException if no executor service with the specified name exists * @throws IllegalArgumentException if no executor service with the specified name exists