diff --git a/activemq-core/src/main/java/org/apache/activemq/broker/region/Queue.java b/activemq-core/src/main/java/org/apache/activemq/broker/region/Queue.java index 5b7df0d0c3..b3c6659587 100755 --- a/activemq-core/src/main/java/org/apache/activemq/broker/region/Queue.java +++ b/activemq-core/src/main/java/org/apache/activemq/broker/region/Queue.java @@ -885,9 +885,12 @@ public class Queue extends BaseDestination implements Task { log.error("Failed to page in more queue messages ", e); } } - while (!messagesWaitingForSpace.isEmpty() && !memoryUsage.isFull()) { - Runnable op = messagesWaitingForSpace.removeFirst(); - op.run(); + + synchronized(messagesWaitingForSpace) { + while (!messagesWaitingForSpace.isEmpty() && !memoryUsage.isFull()) { + Runnable op = messagesWaitingForSpace.removeFirst(); + op.run(); + } } return false; }