考试第五题

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

}

猜你喜欢

转载自www.cnblogs.com/bichen-01/p/11336301.html