1 21 22 package org.armedbear.j; 23 24 import java.util.ArrayList ; 25 26 public final class PendingOperations implements Runnable 27 { 28 private ArrayList operations; 29 30 public PendingOperations() 31 { 32 } 33 34 public synchronized void add(Object object) 35 { 36 if (operations == null) 37 operations = new ArrayList (); 38 operations.add(object); 39 } 40 41 public synchronized void remove(Object object) 42 { 43 operations.remove(object); 44 if (operations.size() == 0) 45 notify(); 46 } 47 48 public synchronized void run() 49 { 50 if (operations != null && operations.size() > 0) { 51 Editor.currentEditor().status("Completing pending operations..."); 52 while (operations.size() > 0) { 53 try { 54 wait(); 55 } 56 catch (InterruptedException e) { 57 Log.error(e); 58 } 59 } 60 } 61 } 62 } 63 | Popular Tags |