第十六周作业

一、题目

编写一个应用程序,利用Java多线程机制,实现时间的同步输出显示。

二、程序代码

 

package zcy;

import java.util.Date;

 class TimeThread extends Thread{
    @Override
    public void run() {
         while(true){
                Date nowTime=new Date();
                System.out.println(nowTime);
                try {
                    FigThread.sleep(1000);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
         }
    }

public static void main(String[] args){
    TimeThread time = new TimeThread();
    time.start();
}
 }

 

三、成功截图

posted on 2019-12-23 14:40  Zy钰  阅读(88)  评论(0编辑  收藏  举报

导航