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 time!");
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
        };
        countdown.start();

        while (!outOfTime) {
            try {
                Thread.sleep(1000);
                System.out.println("do other stuff here");
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
    }
}

```

While this worked, more-or-less, it seemed like there should be a better way of doing this.

After some searching, I found a bunch of questions like these but they don't really address what I'm trying to do:

* [How do I schedule a task to run at periodic intervals?](https://stackoverflow.com/questions/4544197/how-do-i-schedule-a-task-to-run-at-periodic-intervals)
* [How i can run my TimerTask everyday 2 PM](https://stackoverflow.com/questions/9375882/how-i-can-run-my-timertask-everyday-2-pm)
* [How to run certain task every day at a particular time using ScheduledExecutorService?](https://stackoverflow.com/questions/20387881/how-to-run-certain-task-every-day-at-a-particular-time-using-scheduledexecutorse)
* [Java execute task with a number of retries and a timeout](https://stackoverflow.com/questions/11751329/java-execute-task-with-a-number-of-retries-and-a-timeout/)

I don't need anything this complicated; I just want to do a single thing after a certain amount of time while letting the rest of the program still run.

How should I go about scheduling a one-time task to "do a thing"?