synchronized(mutex) {  for(int i=0; i < mbrs.size(); i++) { addr=(Address) mbrs.elementAt(i); if(!received.containsKey(addr)) received.put(addr, max_credits_constant); if(!sent.containsKey(addr)) sent.put(addr, max_credits_constant);
if(Util.acquire(lock)) { try {  for(int i=0; i < mbrs.size(); i++) { addr=(Address) mbrs.elementAt(i); if(!received.containsKey(addr)) received.put(addr, max_credits_constant); if(!sent.containsKey(addr)) sent.put(addr, max_credits_constant); }  for(Iterator it=received.keySet().iterator(); it.hasNext();) { addr=(Address) it.next(); if(!mbrs.contains(addr)) it.remove(); }   for(Iterator it=sent.keySet().iterator(); it.hasNext();) { addr=(Address)it.next(); if(!mbrs.contains(addr)) it.remove(); }   for(int i=0; i < creditors.size(); i++) { Address creditor=(Address)creditors.get(i); if(!mbrs.contains(creditor)) creditors.remove(creditor); }  if(trace) log.trace("creditors are " + creditors); if(insufficient_credit && creditors.size() == 0) { lowest_credit=computeLowestCredit(sent); insufficient_credit=false; mutex.broadcast(); }
    private void handleViewChange(Vector mbrs) {        Address addr;        if(mbrs == null) return;        if(trace) log.trace("new membership: " + mbrs);        synchronized(mutex) {            // add members not in membership to received and sent hashmap (with full credits)            for(int i=0; i < mbrs.size(); i++) {                addr=(Address) mbrs.elementAt(i);                if(!received.containsKey(addr))                    received.put(addr, max_credits_constant);                if(!sent.containsKey(addr))                    sent.put(addr, max_credits_constant);            }            // remove members that left            for(Iterator it=received.keySet().iterator(); it.hasNext();) {                addr=(Address) it.next();                if(!mbrs.contains(addr))                    it.remove();            }            // remove members that left            for(Iterator it=sent.keySet().iterator(); it.hasNext();) {                addr=(Address)it.next();                if(!mbrs.contains(addr))                    it.remove(); // modified the underlying map            }            // remove all creditors which are not in the new view            for(int i=0; i < creditors.size(); i++) {                Address creditor=(Address)creditors.get(i);                if(!mbrs.contains(creditor))                    creditors.remove(creditor);            }            if(trace) log.trace("creditors are " + creditors);            if(insufficient_credit && creditors.size() == 0) {                lowest_credit=computeLowestCredit(sent);                insufficient_credit=false;                mutex.notifyAll();            }        }    }