title: java process is frozen(?) on linux
body: <p>This is my first question on S.O.<br>
  I have a very odd problem.<br>
  Below is my problem...  </p>
  
  <p>I write very simple method that write some text to a file.<br>
  Of course it works well my machine(XP, <strong>4CPU</strong>, jdk1.5.0_17[SUN])<br>
  But it <strong>somtimes</strong> freezes on operating server<br>
  (Linux Accounting240 2.4.20-8smp, <strong>4CPU</strong>,  jdk1.5.0_22[SUN]).  </p>
  
  <p><strong>kill -3 doesn't work.<br>
  ctrl + \ doesn't work.</strong></p>
  
  <p>So, I can't show you the thread dump.</p>
  
  <p>It freezes well..
  When I just write some Thread.sleep(XX) at this method, the problem is gone well(?)...<br>
  <strong>sleep(XX) break... it happened again today with Thread.sleep(XX)...</strong>  </p>
  
  <p>Do you know this problem?
  Do you have the some solution about that?
  Thanks. :-)</p>
  
  <p>P.S.<br>
  linux distribution: Red Hat Linux 3.2.2-5<br>
  command: java -cp . T  </p>
  
  <pre><code>import java.io.BufferedWriter;
  import java.io.File;
  import java.io.FileOutputStream;
  import java.io.OutputStreamWriter;
  import java.text.SimpleDateFormat;
  import java.util.Date;
  
  public class T {
  private BufferedWriter writer = null;
  
  private void log(String log) {
      try {
          if (writer == null) {
              File logFile = new File("test.log");
              writer = new BufferedWriter(new OutputStreamWriter(
                      new FileOutputStream(logFile, true)));
          }
          writer.write(new SimpleDateFormat("[yyyy-MM-dd HH:mm:ss] ")
                  .format(new Date()));
          writer.write("[" + log + "]" + "\n");
          writer.flush();
  
           /*
                           *  this is ad hoc solution ???
                           */
          //Thread.sleep(10);
      } catch (Exception e) {
          e.printStackTrace();
      } finally {         
      }
  
  }
  
  public void test() {
      long startTime = System.currentTimeMillis();
  
      while (true) {
          log(String.valueOf(System.currentTimeMillis()));
          System.out.println(System.currentTimeMillis());
          try {
              //Thread.sleep((int) (Math.random() * 100));
          } catch (Exception e) {
              break;
          }
  
          if (System.currentTimeMillis() - startTime &gt; 1000 * 5) {
              break;
          }
      }
  
      if (writer != null) {
          try {
              writer.close();
          } catch (Exception e) {
          }
      }
      System.out.println("OK");
  }
  
  public static void main(String[] args) {
      new T().test();
  }
  }
  </code></pre>