title: How to make a thread sleep for specific amount of time in java?
body: <p>I have a scenario where i want a thread to sleep for specific amount of time.</p>
  
  <p>Code:</p>
  
  <pre><code>    public void run(){
          try{
              //do something
                       Thread.sleep(3000);
  //do something after waking up
                  }catch(InterruptedException e){
                  // interrupted exception hit before the sleep time is completed.so how do i make my thread sleep for exactly 3 seconds?
                  }
          }
  </code></pre>
  
  <p>Now how do i handle the case where the thread i am trying to run is hit with an interrupted exception before the complete of the sleep? Also does the thread wake up after being interrupted and does it go to runnable state or when is it that only after it goes to runnable does the flow go to catch block?</p>