Protect the messagesWaitingForSpace variable against concurrent modification.

git-svn-id: https://svn.apache.org/repos/asf/activemq/trunk@633210 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Hiram R. Chirino 2008-03-03 18:03:21 +00:00
parent e376456111
commit 3d18d59904
1 changed files with 6 additions and 3 deletions

View File

@ -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;
}