diff --git a/src/dorkbox/network/connection/EndPoint.java b/src/dorkbox/network/connection/EndPoint.java index e03cfbc6..0602ff04 100644 --- a/src/dorkbox/network/connection/EndPoint.java +++ b/src/dorkbox/network/connection/EndPoint.java @@ -278,7 +278,13 @@ class EndPoint { // we want to WAIT until after the event executors have completed shutting down. List> shutdownThreadList = new LinkedList>(); - for (EventLoopGroup loopGroup : eventLoopGroups) { + List loopGroups; + synchronized (eventLoopGroups) { + loopGroups = new ArrayList(eventLoopGroups.size()); + loopGroups.addAll(eventLoopGroups); + } + + for (EventLoopGroup loopGroup : loopGroups) { shutdownThreadList.add(loopGroup.shutdownGracefully(maxShutdownWaitTimeInMilliSeconds, maxShutdownWaitTimeInMilliSeconds * 4, TimeUnit.MILLISECONDS));