public class ShutdownHelper extends Object
ExecutorService
.Modifier and Type | Field and Description |
---|---|
protected static org.apache.log4j.Logger |
log |
Constructor and Description |
---|
ShutdownHelper(ExecutorService executorService)
Issues the
ExecutorService.shutdown() request and then waits
until all tasks running on that service have terminated. |
ShutdownHelper(ExecutorService executorService,
long logTimeout,
TimeUnit unit)
Issues the
ExecutorService.shutdown() request and then waits
until all tasks running on that service have terminated. |
Modifier and Type | Method and Description |
---|---|
long |
elapsed()
The elapsed nanoseconds since the
ExecutorService.shutdown() was
initiated. |
protected void |
logTimeout()
Invoked each time the logTimeout expires awaiting the service
termination.
|
public ShutdownHelper(ExecutorService executorService) throws InterruptedException
ExecutorService.shutdown()
request and then waits
until all tasks running on that service have terminated.
If the caller's Thread
is interrupted while awaiting service
termination, then the caller is responsible for the subsequent behavior.
Common actions include continuing to await shutdown of the service, e.g.,
by invoking this method again, immediately terminating the service, etc.
executorService
- The service to be shutdown.InterruptedException
- If interrupted while awaiting termination of the service.public ShutdownHelper(ExecutorService executorService, long logTimeout, TimeUnit unit) throws InterruptedException
ExecutorService.shutdown()
request and then waits
until all tasks running on that service have terminated.
If the caller's Thread
is interrupted while awaiting service
termination, then the caller is responsible for the subsequent behavior.
Common actions include continuing to await shutdown of the service, e.g.,
by invoking this method again, immediately terminating the service, etc.
executorService
- The service to be shutdown.logTimeout
- The timeout between
#logTimeout(ExecutorService, long, Logger)
notifications.unit
- The unit in which that timeout is expressed.IllegalArgumentException
- if executorService is null
.IllegalArgumentException
- if logTimeout is non-positive.IllegalArgumentException
- if unit is null
.InterruptedException
- If interrupted while awaiting termination of the service.public long elapsed()
ExecutorService.shutdown()
was
initiated. This value is updated every 100ms until the service is
terminated.protected void logTimeout()
Copyright © 2006–2019 SYSTAP, LLC DBA Blazegraph. All rights reserved.