public class MyWait extends Thread {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss:SSS");
public void run() {
synchronized (this) {
while (true) {
System.out.println(sdf.format(new Date()));
try {
this.wait(1000);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
}
public static void main(String[] args) {
new MyWait().start();
new MyWait().start();
}
}
慕仰7261054
ABrondly
AndyJaa
摩诃迦叶
相关分类