If you’ve ever sat mesmerized by the spinning Java compiler, you’re not
alone. To set a timer for running a job or task in Java, create a timer
using the code Timer timer = new Timer();. Then, schedule the timer to
run the task. If you want to place a limit on the amount of time Java
has to do the job, use the code “TimeoutException” and be sure to tell
Java to stop the task, otherwise it will continue trying to do it in the
background, using up your bandwidth.