title: How to deal with: Call to 'Thread.sleep()' in a loop, probably busy-waiting
body: <p>Guys how to deal with such code and warning?</p>
  <pre><code>private void listenOnLogForResult() {
      String logs = &quot;&quot;;
      int timeCounter = 1;
      while (logs.isEmpty()) {
          try {
              timeCounter++;
              Thread.sleep(2000); // Wait 2 seconds
          } catch (InterruptedException e) {
              log.error(e.getLocalizedMessage(), e);
          }
          if (timeCounter &lt; 30) {
              logs = checkLogs()
          } else {
              logs = &quot;Time out&quot;;
          }
      }
  }
  </code></pre>
  <p>I need to pause current thread for 2 seconds to wait file to be filled, but my Intelij Rise an issue here.
  <a href="https://i.stack.imgur.com/C77VX.png" rel="noreferrer"><img src="https://i.stack.imgur.com/C77VX.png" alt="enter image description here" /></a>
  And also I am getting error from sonar:
  SonarLint: Either re-interrupt this method or rethrow the &quot;InterruptedException&quot;.</p>
  <p>I've tried already with many <code>ExecutorService</code>, but it is always run in seperate thread, and I need to pause current one.</p>
  <p>Please help..</p>