HCOLL-216 added better close support for the executor

This commit is contained in:
Rob Austin
2014-11-25 15:17:53 +00:00
parent 97405a73ce
commit 21b0d96493
@@ -38,10 +38,7 @@ import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.nio.channels.SocketChannel;
import java.util.*;
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;
import java.util.concurrent.*;
import static java.nio.ByteBuffer.allocateDirect;
import static net.openhft.chronicle.map.AbstractChannelReplicator.SIZE_OF_SIZE;
@@ -309,6 +306,19 @@ class StatelessChronicleMap<K, V> implements ChronicleMap<K, V>, Closeable, Clon
if (closeables != null)
closeables.closeQuietly();
closeables = null;
if (executorService != null) {
executorService.shutdown();
try {
if (!executorService.awaitTermination(20, TimeUnit.SECONDS)) {
executorService.shutdownNow();
}
} catch (InterruptedException e) {
LOG.error("", e);
}
}
try {
Thread.sleep(100);
} catch (InterruptedException e) {