title: How to log an error after every certain number of tries during sleeping the thread?
body: <p>I have a while loop which checks <code>verifySystem</code> method to see whether it returns true or not. If it is not returning true then it will sleep for 5 minutes and then again calls <code>verifySystem</code> method after 5 minutes to see it returns true or not.</p>
  
  <pre><code>    while (!verifySystem(name, value)) {
          Thread.sleep(5 * 60 * 1000); // sleeping for 5 minutes
      }
  </code></pre>
  
  <p>So suppose for whatever reason, that method doesn't returns true, then my program will always keep on running forever.. </p>
  
  <p>So I am thinking to have a check like if it has sleep for atleast 10 times, then I would log an error using <code>System.out.println()</code> for now. I will use logger once I am intergrating my code..</p>
  
  <p>How would I add this logic of 10 times check and if it has tried more than 10 times, then log an error and reset the counter.. So again it will start calling <code>verifySystem</code> method every 5 minutes to see whether that method is returning true or not..</p>
  
  <p>In short, it will log an error after every 10 tries but it will reset the counter after that..</p>