while
(
true
) {
Thread.sleep(
1000
);
//等待1S
System.out.println(
"----------"
);
}
To limit the output end of the times: for example: the output end of the fifth
int a = 0;
while
(a<5
) {
Thread.sleep(
1000
);
//等待1S
a+= 1;
System.out.println(
"-----"
);
}