线程运行时间(1)

package cn.zy;

import java.util.Date;
import java.text.SimpleDateFormat;

public class Demo01 {
  public static void main(String[] args) {
	  class OneThread extends Thread{
		@Override
		public void run() {
			SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
			while(true){
				Date d=new Date();
				String str=sdf.format(d);
				System.err.println(str);
				try {
					Thread.sleep(1000);
				} catch (InterruptedException e) {
					e.printStackTrace();
				}
			}
			
        }
	
	  }
	  OneThread one=new OneThread();
	  one.start();
}
}

你可能感兴趣的:(线程运行时间(1))