title: What is the best way to stop execution for few seconds in java?
body: <p>I am new to Java. I tried to write a program to check database status (overloaded or not). </p>
  
  <p><strong>CODE:</strong></p>
  
  <pre><code>package com.test.service;
  
  import java.util.LinkedList;
  import java.util.List;
  
  public class PersonImpl {
  
      public PersonService personService;
  
      public void InsertPersonDetails(Person person) {
  
          if(personService.isOverLoaded()) {
              try {
                  Thread.sleep(5000);
              } catch (InterruptedException e) {
                  e.printStackTrace();
              }
          } else {
              //pass control to dao
          }
      }
  }
  </code></pre>
  
  <p>Here I will get <code>boolean</code> from <code>isOverLoaded</code>. If <code>isOverLoaded</code> value is yes then we should stop passing control to dao for few seconds and then check <code>isOverLoaded</code> method again. </p>
  
  <p>Help would be appreciated :)</p>