[concurrency-interest] Question / Feature Request for ExecutorService

Joe Bowbeer joe.bowbeer at gmail.com
Wed Nov 16 17:05:00 EST 2011


With ThreadPoolExecutor, you have the API to accomplish this in a couple of
ways.

1: tpe.shutdown(); tpe.getQueue().drainTo(submitted);

The above is similar to what shutdownNow does.

2. Another way would be to wrap the tasks on submission with a Runnable
that checks isTerminating() and punts if it is true.

Joe

On Wed, Nov 16, 2011 at 1:31 PM, Morgan Conrad <morganconrad at yahoo.com>wrote:

> This question came up on StackOverflow.
>
> see
> http://stackoverflow.com/questions/8158500/with-a-java-executorservice-how-do-i-complete-actively-executing-tasks-but-halt
>
> Basically, the request seems reasonable:
>
> "I want to call a command that:
>  a. Completes the currently active task or tasks (like shutdown).
>   b. Halts the processing of waiting tasks (like shutdownNow)."
>
> Is there a good way to do this using the existing code?
>
> Sincerely,
> Morgan Conrad
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://cs.oswego.edu/pipermail/concurrency-interest/attachments/20111116/02e3ba8b/attachment.html>


More information about the Concurrency-interest mailing list