线程运行时间(2)

package cn.zy;

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


public class Demo02 {
	public static void main(String[] args) {
    class MyThread implements Runnable{

		@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();
		        }
    	
             }

	      }

       }
	    MyThread mt=new MyThread();
	    Thread t=new Thread(mt);
	    t.start();
}
}

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