title: how to properly sleep in loop
body: <p>I have a loop who's job is to act as a blocking command,  execute a shell command once every second. Java warns about "sleeping in loop".  Here is the code:</p>
  
  <pre><code>    while (!Shell.silentShellCommand(stringCommand).contains("Device detected")) {
          try {
              Thread.sleep(1000);
          } catch (InterruptedException ex) {
              log.errorHandler(ex);
          }
      }
  </code></pre>
  
  <p>Surely there is a better way to do this.  I just don't know how.  What would be the proper way to make a "blocking timer method"?   I am using this to pause execution until the user does something. </p>