public void submit(final Runnable task) throws InterruptedException {
this.semaphore.acquire();
- try {
- this.pool.execute(new Runnable() {
- public void run() {
- try {
- task.run();
- } finally {
- BlockingExecutorService.this.semaphore.release();
+ if (!this.pool.isShutdown()) {
+ try {
+ this.pool.execute(new Runnable() {
+ public void run() {
+ try {
+ task.run();
+ } finally {
+ BlockingExecutorService.this.semaphore.release();
+ }
}
- }
- });
- } catch (final RejectedExecutionException e) {
- this.semaphore.release();
+ });
+ } catch (final RejectedExecutionException e) {
+ this.semaphore.release();
+ }
}
}
+ public void shutdown() {
+ this.pool.shutdown();
+ }
+
+ public void shutdownNow() {
+ this.pool.shutdownNow();
+ }
+
}