Code example for ConcurrentModificationException

0
  /** 
   * Starts a thread (through the executor) that connects to the server on a regular base 
   */ 
  public synchronized void open(Receiver receiver) {
    if (isStarted) {
      throw new ConcurrentModificationException("Cannot call open more than once!");
    } 
    isStarted = true;
    this.receiver = receiver;
    env.execute(this);
  } 
 
  /** 
   * Enqueues an object for transmission. 
   */ 
  public void send(String message) {
    outqueue.add(message);
  } 
 
  /** 
   * For unit tests, retrieve the queue that internally stores the XML snippets.