title: What can cause a hanging in this "harmless" sequence of Java commands?
body: <p>One of the constructors has the following sequence of the commands:</p>
  
  <pre><code>log.info("A new session of the game started.");
  clientsListener = new ClientsListener(earPort, userName, players, this);
  </code></pre>
  
  <p>In the log file I have the statement produced by the first line of the code. The constructor of the <code>ClientsListener</code> is written in the following way:</p>
  
  <pre><code>public ClientsListener(int earPort, String userName, String[] players, Game game) {
     this.earPort = earPort;
     this.userName = userName;
     this.players = players;
     this.game = game;
     ServiceBrowser browser;
     for (String playerName: players) {
        String serviceType = "_" + playerName + "._tcp.";
        browser = BrowsersGenerator.getBrowser(serviceType,game);
        browser.post(userName + ":infoRequest=infoRequest");
     }
  }
  </code></pre>
  
  <p>The <code>BrowsersGenerator.getBrowser</code> has the following simple sequence of commands:</p>
  
  <pre><code>public static ServiceBrowser getBrowser(String serviceType, Game game) {
     if (!name2browser.containsKey(serviceType)) {
        name2browser.put(serviceType, new ServiceBrowser(serviceType, game));
     }
     return name2browser.get(serviceType);
  }
  </code></pre>
  
  <p>In the above method I instantiate the <code>ServiceBrowser</code>. The constructor of this class is:</p>
  
  <pre><code>public ServiceBrowser(String serviceType, Game game) {
     this.serviceType = serviceType;
     this.game = game;
     status = "notActivated";
  }
  </code></pre>
  
  <p>Then, in the constructor of the <code>ClientsListener</code> (the second block of the code) I call <code>browser.post</code>. The first line of this method contains the following:</p>
  
  <pre><code>game.log.fine("We entered the post method");
  </code></pre>
  
  <p>And this statement is absent in the log file. So, the software hangs somewhere between the two attempts to write to the log file. I cannot figure out where is a gangrenous part of the code. Everything looks save to me. The main problem is that I cannot reproduce the problem. I happens very rare and I have only one log file to analyze. Could anybody, please, help me with that?</p>