diff --git a/src/main/java/org/jboss/netty/handler/execution/MemoryAwareThreadPoolExecutor.java b/src/main/java/org/jboss/netty/handler/execution/MemoryAwareThreadPoolExecutor.java
index <HASH>..<HASH> 100644
--- a/src/main/java/org/jboss/netty/handler/execution/MemoryAwareThreadPoolExecutor.java
+++ b/src/main/java/org/jboss/netty/handler/execution/MemoryAwareThreadPoolExecutor.java
@@ -438,7 +438,9 @@ public class MemoryAwareThreadPoolExecutor extends ThreadPoolExecutor {
         //System.out.println("D: " + totalCounter + ", " + increment);
         if (maxTotalMemorySize != 0 && totalCounter + increment >= maxTotalMemorySize) {
             //System.out.println("RELEASE: " + task);
-            semaphore.release();
+            while (semaphore.hasQueuedThreads()) {
+                semaphore.release();
+            }
         }
 
         if (task instanceof ChannelEventRunnable) {
Fixed a dead lock where MemoryAwareThreadPoolExecutor does not release its semaphore completely