title: Is it okay to use Thread.sleep() in a loop in Java, to do something at regular intervals?
body: <p>I have read some threads that said that calling Thread.sleep() in a loop is problematic and is a serious performance issue. But in some cases it seems the most natural thing to do.</p>
  
  <p>For example if I want my application to do something every <strong>3 minutes</strong> (lets say it's an <strong>autosave</strong>)</p>
  
  <pre><code>public void startAutosaveLoop(){
      stop = false;
      new Thread(new Runnable() {
  
          @Override
          public void run() {
              while (!stop){
                  Thread.sleep(T*1000);
                  if (!stop){
                      // do something
                  }
              }
          }
      }).start();
  }
  </code></pre>
  
  <p>Is there a better way to doing this? Is this kind of situation problematic?</p>