title: How To Exit Infinite Loop Without Pausing Java
body: <p>I have a Java program that automates a long list of tasks and it pauses for 15 seconds after each completed task then restarts. Is there a way to end this program by entering any keystrokes from the user? I don't want to have to ask the user if they want to end the program and have to stop and ask every so often as the user is not going to be around to respond. I know you can press "Control + C" to stop the program while in the command prompt but is there a more elegant way than this?
  The program is something like this:</p>
  
  <pre><code>while(true) {
  // automatic task code
  }
  </code></pre>
  
  <p>Thank You</p>
  
  <p>**Edit* My question is more of a "Can I make a program when I input an unsolicited input that can abruptly end the program?"</p>