title: How to stop execution after a certain time in Java?
body: <p>In the code, the variable timer would specify the duration after which to end the while loop, 60 sec for example.</p>
  
  <pre><code>   while(timer) {
      //run
      //terminate after 60 sec
     }
  </code></pre>