package Chapter7.ShiLi.Demo6;
public class ThreadDemo {
public static void main(String[] args) {
System.out.println("Wait");
Wait.bySec(5);
System.out.println("start");
}
}
package Chapter7.ShiLi.Demo6;
public class Wait {
public static void bySec(long s){
for (int i = 0; i < s; i++) {
System.out.println(i+1+"秒");
try {
Thread.sleep(1000);//睡眠1秒
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
}