Iterator iter = new HashSet(sessions.values()).iterator(); while (iter.hasNext())
for(Iterator i = new HashSet(sessions.values()).iterator(); i.hasNext(); )
   public void close() throws JMSException   {      try      {         closeLock.writeLock().acquire();      }      catch (InterruptedException e)      {         //Ignore      }      try      {         if (trace) { log.trace("close()"); }                  if (closed)         {            log.warn("Connection is already closed");            return;         }                   //We clone to avoid concurrent modification exceptions         Iterator iter = new HashSet(sessions.values()).iterator();         while (iter.hasNext())         {            ServerSessionEndpoint sess = (ServerSessionEndpoint)iter.next();            sess.close();         }                  iter = temporaryDestinations.iterator();         while (iter.hasNext())         {            JBossDestination dest = (JBossDestination)iter.next();            channelMapper.undeployCoreDestination(dest.isQueue(), dest.getName());         }                  temporaryDestinations.clear();         consumers.clear();         cm.unregisterConnection(remotingClientSessionId);         JMSDispatcher.instance.unregisterTarget(new Integer(connectionID));         closed = true;      }      finally      {         closeLock.writeLock().release();      }   }