diff --git a/src/main/java/org/jboss/netty/handler/execution/OrderedMemoryAwareThreadPoolExecutor.java b/src/main/java/org/jboss/netty/handler/execution/OrderedMemoryAwareThreadPoolExecutor.java index 16a7c930e6..7b186ef459 100644 --- a/src/main/java/org/jboss/netty/handler/execution/OrderedMemoryAwareThreadPoolExecutor.java +++ b/src/main/java/org/jboss/netty/handler/execution/OrderedMemoryAwareThreadPoolExecutor.java @@ -294,9 +294,12 @@ public class OrderedMemoryAwareThreadPoolExecutor extends } public void run() { + boolean acquired = false; + // check if its already running by using CAS. If so just return here. So in the worst case the thread // is executed and do nothing if (isRunning.compareAndSet(false, true)) { + acquired = true; try { Thread thread = Thread.currentThread(); for (;;) { @@ -323,6 +326,11 @@ public class OrderedMemoryAwareThreadPoolExecutor extends // set it back to not running isRunning.set(false); } + + if (acquired && !isRunning.get() && tasks.peek() != null) { + doUnorderedExecute(this); + } + } } }