class ExecutorServiceExtensions extends Object
Extensions to the ExecutorService interface.
| Constructor and description |
|---|
ExecutorServiceExtensions() |
| Type Params | Return Type | Name and description |
|---|---|---|
<T> |
static T |
executeAndShutdown(ExecutorService self, int awaitValue, TimeUnit awaitUnit, Closure<T> closure)Execute the given closure, performing a shutdown after it has exited (see shutdownAwaitTermination(ExecutorService, int, TimeUnit)). |
|
static void |
shutdownAwaitTermination(ExecutorService self, int awaitValue, TimeUnit awaitUnit)Initiate a shutdown, waiting the specified amount of time before forcing termination. |
Execute the given closure, performing a shutdown after it has exited (see shutdownAwaitTermination(ExecutorService, int, TimeUnit)).
def executorService = Executors.newCachedThreadPool()
executorService.executeAndShutdown { e ->
// Use the executorService within this closure
}
assert executorService.shutdown
closure
- Called within the context of a try/finally block with the executor
service itself for performing any parallel tasks.Initiate a shutdown, waiting the specified amount of time before forcing termination.