考试第五题

package test05;

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

public class Demo implements Runnable{

    @Override
    public void run() {
        // TODO Auto-generated method stub
        
        Date date = new Date();
        
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("HH:mm:ss");
    
        String s = simpleDateFormat.format(date);
        System.out.println(s);
    }
    public static void main(String[] args) {
        Demo d = new Demo();
        
        while(true) {
            
            Thread t = new Thread(d);
            try {
                t.sleep(1000);
            } catch (InterruptedException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
            t.start();
            
        }
        
    }
    

}

 

posted @ 2019-08-11 19:30  AxeBurner  阅读(99)  评论(0编辑  收藏  举报