title: The difference between "BLOCKED" and "TIMED_WAITING" on java
body: <p>Our tomcat didn't reponse any request. When I used "jstack pid" to print stack info, I got the following information. I find it was blocked on "Thread.sleep(long)". I think it should be the "TIMED_WAITING". Why?</p>
  
  <pre><code>Thread 24836: (state = BLOCKED)
  - java.lang.Thread.sleep(long) @bci=0 (Compiled frame; information may be imprecise)
  - com.lagou.base.proxy.MasterTemplateContainer.checkMaster(org.springframework.orm.hibernate3.HibernateTemplate) @bci=128, line=221 (Compiled frame)
  - com.lagou.base.proxy.MasterTemplateContainer.access$1(com.lagou.base.proxy.MasterTemplateContainer, org.springframework.orm.hibernate3.HibernateTemplate) @bci=2, line=185 (Interpreted frame)
  - com.lagou.base.proxy.MasterTemplateContainer$2.run() @bci=8, line=134 (Interpreted frame)
  - java.util.concurrent.ThreadPoolExecutor.runWorker(java.util.concurrent.ThreadPoolExecutor$Worker) @bci=95, line=1145 (Interpreted frame)
  - java.util.concurrent.ThreadPoolExecutor$Worker.run() @bci=5, line=615 (Interpreted frame)
  - java.lang.Thread.run() @bci=11, line=744 (Interpreted frame)
  
  
  Thread 24835: (state = BLOCKED)
  - java.lang.Thread.sleep(long) @bci=0 (Compiled frame; information may be imprecise)
  - com.lagou.base.proxy.MasterTemplateContainer.checkMaster(org.springframework.jdbc.core.JdbcTemplate) @bci=128, line=177 (Compiled frame)
  - com.lagou.base.proxy.MasterTemplateContainer.access$0(com.lagou.base.proxy.MasterTemplateContainer, org.springframework.jdbc.core.JdbcTemplate) @bci=2, line=141 (Interpreted frame)
  - com.lagou.base.proxy.MasterTemplateContainer$1.run() @bci=8, line=125 (Interpreted frame)
  - java.util.concurrent.ThreadPoolExecutor.runWorker(java.util.concurrent.ThreadPoolExecutor$Worker) @bci=95, line=1145 (Interpreted frame)
  - java.util.concurrent.ThreadPoolExecutor$Worker.run() @bci=5, line=615 (Interpreted frame)
  - java.lang.Thread.run() @bci=11, line=744 (Interpreted frame)
  </code></pre>
  
  <p>My code:</p>
  
  <pre><code>private void checkMaster(HibernateTemplate hdao) {
      int loopErrors = errorTimes;
      int loopSuccess = successTimes;
      while(true) {
          boolean success = true;
          try {
              if(hdao == null){
                  success = false;
                  continue;
              }
              success = checkMasterStatusOnce(hdao);//try access database to get the status
          } catch (Exception e1) {
              logger.error("",e1);
              success = false;
          }
  
      try {
          Thread.sleep(checkInterval);
      } catch (InterruptedException e) {
          e.printStackTrace();
      }
  }
  }
  </code></pre>
  
  <p>the method is invoked in</p>
  
  <pre><code>public void check() {
      for (final JdbcTemplate jdao : jdbcTemplates) {
          threadPoolExecutor.execute(new Runnable(){
              public void run() {
                  checkMaster(jdao);
              }
          });
      }
  }
  </code></pre>