我将如何在 Java 中的 while 循环中实现计时器?
while (game not ended) {
//do something
(wait 5 seconds)
}
会是这样吗?:(java.util.Timer
)
int delay = 1000; //milliseconds
while (game not ended) {
//do something
new Timer(delay, taskPerformer).start();
}