title: Java: Calling method from threads one after another
body: <p>I have class Server and subclass ClientThread. ClientThread has methods receive() and broadcast(String[] msg) used to receive and send messages from/to clients connected to server.</p>
  
  <p>Scheme:</p>
  
  <pre><code>public class Server extends Thread {
      private ArrayList&lt;ClientThread&gt; clientThreads;
      class ClientThread extends Thread {
          public void broadcast(String[] msg) {...}
          public void receive() {
              ...
              if (msg.equals("CHANGED")) {
                  resumeOthers();
          }
  
          public void suspendOthers() {
              for (ClientThread c: clientThreads)
                   if (c!=this)
                       try {
                           c.wait();
                       } catch (InterruptedException e) {}
          }
  
          public void resumeOthers() {
              for (ClientThread c: clientThreads)
              if (c!=this)
                  c.notify();
          }
      }
  
      public void run() {
          ...
          cmd = new String[1];
          cmd[0] = "PROMPTCHANGE";
          for (ClientThread currPlayer: clientThreads) {
              currPlayer.broadcast(cmd);
              currPlayer.suspendOthers();
          }
      }
  }
  </code></pre>
  
  <p>Now, I would like to make this ClientThreads work one after another, like this:</p>
  
  <pre><code>1. ClientThread number 1 is calling method broadcast.
  Now any other ClientThread existing is freezed
  (they are stored in ArrayList on Server)
  
  2. Client (another class) replies with a message that is being caught by receive()
  Now this thread is freezed, and the next one starts running
  </code></pre>
  
  <p>Unfortunately, my approach doesn't work.
  Could somebody explain me in details how to achieve that?</p>