线程中的sleep
package com.com.Prioity;
import java.text.SimpleDateFormat;
import java.util.Date;
public class MyThread extends Thread{
@Override
public void run() {
while (true){
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Date d = new Date();
System.out.println(sdf.format(d));
try {
Thread.sleep(1000);//睡一秒钟
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
public static void main(String[] args) {
MyThread mt= new MyThread();
mt.start();
}
}