fix some synchronization problems

git-svn-id: https://svn.apache.org/repos/asf/activemq/trunk@509115 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Robert Davies 2007-02-19 06:56:59 +00:00
parent 0384cabd9d
commit 0cda6b0d58
1 changed files with 5 additions and 7 deletions

View File

@ -46,7 +46,7 @@ public class FilePendingMessageCursor extends AbstractPendingMessageCursor imple
private ListContainer diskList;
private Iterator iter=null;
private Destination regionDestination;
private AtomicBoolean iterating=new AtomicBoolean();
private boolean iterating;
private boolean flushRequired;
private AtomicBoolean started=new AtomicBoolean();
@ -88,14 +88,12 @@ public class FilePendingMessageCursor extends AbstractPendingMessageCursor imple
*
*/
public synchronized void reset(){
synchronized(iterating){
iterating.set(true);
}
iterating=true;
iter=isDiskListEmpty()?memoryList.iterator():getDiskList().listIterator();
}
public synchronized void release(){
iterating.set(false);
iterating=false;
if(flushRequired){
flushRequired=false;
flushToDisk();
@ -246,9 +244,9 @@ public class FilePendingMessageCursor extends AbstractPendingMessageCursor imple
public void onMemoryUseChanged(UsageManager memoryManager,int oldPercentUsage,int newPercentUsage){
if(newPercentUsage>=getMemoryUsageHighWaterMark()){
synchronized(iterating){
synchronized(this){
flushRequired=true;
if(!iterating.get()){
if(!iterating){
flushToDisk();
flushRequired=false;
}