如何制作一个循环 25 次、等待 5 分钟然后开始下一批 25 次的循环? java

How to make a loop that loops 25 times, waits 5 minutes and then starts the next batch of 25? java

我知道我会有一个 for loop 看起来像这样。但除此之外,我不知道它会重新启动:

for (int i = 0; i < 25; i++) {
    // my code here
}

要暂停循环所在的线程 运行,请使用;

Thread.sleep (num_milliseconds);

如果您希望它每 5 分钟 运行 只需使用

while (true){
    for (int i = 0; i<25; i++){
        // your code
        Thread.sleep(300000);
    }
}