title: Java execute method from within a loop every few seconds
body: <p>I have a Thread that runs in my test app with a while loop inside the thread. While the while loop is running i want to execute a method from within this while loop every 30 seconds. Inside the while loop, don't want to sleep the thread or stop the loop, it must run and every 30 seconds call the method.</p>
  
  <pre><code> Thread myThread = new Thread() {
       @Override
       public void run() {
          //my code that runs with a loop
          //while loop here that runs and needs to execute method every 30 seconds, if condition met continue else break;
       };
       myThread.start();
   }
  </code></pre>