title: java using 100% cpu
body: <p>I have a java app running on CentOS 6.0. It always runs in background via cron. Sometimes this app goes into wait state while using 100% cpu. </p>
  
  <p>My java version is :</p>
  
  <pre><code>java version "1.6.0_17"
  OpenJDK Runtime Environment (IcedTea6 1.7.4) (rhel-1.21.b17.el6-x86_64)
  OpenJDK 64-Bit Server VM (build 14.0-b16, mixed mode)
  </code></pre>
  
  <p>Other symptoms are :</p>
  
  <p>a. One thread of the process seems to be in a loop waiting for something. When traced using strace, it shows following o/p continuously :</p>
  
  <blockquote>
  <pre><code>futex(0x7fb8000ac728, FUTEX_WAKE_PRIVATE, 1) = 0
  futex(0x7fb8000ac754, FUTEX_WAIT_BITSET_PRIVATE|FUTEX_CLOCK_REALTIME, 1, {1340347489,&gt; 822867000}, ffffffff) = -1 ETIMEDOUT (Connection timed out)
  </code></pre>
  </blockquote>
  
  <p>b. It seems like the process has finished working, looking at the files it is using. Only few files are remaining. The output of 'ls /proc/pid/fd/ shows :</p>
  
  <blockquote>
  <pre><code>lr-x------ 1 root root 64 Jun 22 13:13 0 -&gt; pipe:[77107601]
  l-wx------ 1 root root 64 Jun 22 13:13 1 -&gt; pipe:[77120162]
  l-wx------ 1 root root 64 Jun 22 13:13 2 -&gt; /var/log/mithi/mcs/agent_account_mailstore_exceed_limit.sh.log
  lr-x------ 1 root root 64 Jun 22 13:13 3 -&gt; /usr/lib/jvm/java-1.6.0-openjdk-1.6.0.0.x86_64/jre/lib/rt.jar
  </code></pre>
  </blockquote>
  
  <p>Has anybody faced similar situation?
  Any clues or references would be very helpful.</p>
  
  <p>More specifically, are there any known problems in running openjdk based Java processes in background on CentOS 6?</p>
  
  <p>Now I'm able to simulate the problem with a very simple infinite loop, given below</p>
  
  <pre><code>#!/bin/bash
  
  while [ 1 ]
  do
      /usr/lib/jvm/java-1.6.0-openjdk-1.6.0.0.x86_64/bin/java -version &amp;
      sleep 1s
  done
  </code></pre>
  
  <p>When this script is run for about 3 - 4 hours, I find one or two java processes which are hung or in infinite loop with identical symptom i.e </p>
  
  <pre><code>futex(0x7fb8000ac754, FUTEX_WAIT_BITSET_PRIVATE|FUTEX_CLOCK_REALTIME, 1, {1340347489,&gt; 822867000}, ffffffff) = -1 ETIMEDOUT (Connection timed out)
  </code></pre>
  
  <p>This is happening on multiprocessor systems only, not on single processor systems. It can also be simulated on RHEL6, not only CentOS6.</p>