Permalink
Browse files

shutdown executors before connections

Closes #5
  • Loading branch information...
1 parent c0dc601 commit 9241aee2fcd7de74dfcb06de3347a2b83f2e5e7a @notnoop committed Nov 28, 2011
Showing with 9 additions and 1 deletion.
  1. +9 −1 src/main/java/com/notnoop/c2dm/internal/C2DMPooledService.java
@@ -31,6 +31,7 @@
package com.notnoop.c2dm.internal;
import java.util.concurrent.ExecutorService;
+import java.util.concurrent.TimeUnit;
import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
@@ -71,8 +72,15 @@ public void run() {
@Override
public void stop() {
super.stop();
- this.httpClient.getConnectionManager().shutdown();
this.executor.shutdown();
+ try {
+ if(!this.executor.awaitTermination(5, TimeUnit.SECONDS)) {
+ this.executor.shutdownNow();
+ }
+ } catch (InterruptedException e) {
+ }
+
+ this.httpClient.getConnectionManager().shutdown();
}
}

0 comments on commit 9241aee

Please sign in to comment.