Java每隔一段时间输出一句话
while (true) {
Thread.sleep(1000);//等待1S System.out.println("----------");}要限制第几次输出结束:例如: 输出第五次结束
int a = 0;
while (a<5) {
Thread.sleep(1000);//等待1Sa+= 1;
System.out.println("-----");}while (true) {
Thread.sleep(1000);//等待1S System.out.println("----------");}while (a<5) {
Thread.sleep(1000);//等待1S System.out.println("-----");}