diff --git a/activemq-core/src/main/java/org/apache/activemq/ActiveMQMessageConsumer.java b/activemq-core/src/main/java/org/apache/activemq/ActiveMQMessageConsumer.java index 52aa3a9aa3..02fb3fc959 100755 --- a/activemq-core/src/main/java/org/apache/activemq/ActiveMQMessageConsumer.java +++ b/activemq-core/src/main/java/org/apache/activemq/ActiveMQMessageConsumer.java @@ -856,6 +856,9 @@ public class ActiveMQMessageConsumer implements MessageAvailableConsumer, StatsC } } } + // yeild here so that a thread trying to stop unconsumedMessages has + // a chance of getting prioritized head of this thread that is in a dispatch loop. + Thread.yield(); } catch (Exception e) { session.connection.onAsyncException(e); }