Java 延迟时间长程序终止

Java program terminates when delay time is long

我正在编写一个代码,让鼠标每 10 分钟移动一点。 但是,当我在 Robot.delay 函数中输入大于 100,000(10 分钟 = 600,000 毫秒)的值时,程序仅打印 "It works!" 行,然后终止。

为什么会这样?

public class MoveEach10Mins {

static boolean flag;
static int CurrentXpos = 0;
static int CurrentYpos = 0;

public static void main(String[] args) {

    System.out.println("It works!");

    try {
        Robot r = new Robot();
        while (true) {
            PointerInfo a = MouseInfo.getPointerInfo();
            Point b = a.getLocation();
            CurrentXpos = (int) b.getX();
            CurrentYpos = (int) b.getY();

            r.delay(600000);
            if (flag) {
                flag = false;
                r.mouseMove(CurrentXpos - 1, CurrentYpos);
                System.out.println("moved");
            } else {
                flag = true;
                r.mouseMove(CurrentXpos + 1, CurrentYpos);
                System.out.println("moved again");
            }

        }
    } catch (Exception e) {
        // TODO: handle exception
    }

}

}

来自documentation

Throws: IllegalArgumentException - if ms is not between 0 and 60,000 milliseconds inclusive