How do I schedule a task to run once?
I want to delay doing something, along the lines of setting a countdown timer that will "do a thing" after a certain amount of time. I want the rest of my program to keep running while I wait, so I tried making my own Thread that contained a one-minute delay: public class Scratch { private static boolean outOfTime = false; public static void main(String[] args) { Thread countdown = new Thread() { @Override public void run() { try { // wait a while System.out.println("Starting one-minute countdown now..."); Thread.sleep(60 * 1000); // do the thing outOfTime = true; System.out.println("Out of