每隔10秒鐘打印一個“Helloworld”
阿新 • • 發佈:2017-11-13
rac extend out dimp sim exce new row mat
/** * 每隔10秒鐘打印一個“Helloworld” */ public class Test03 { public static void main(String[] args) throws InterruptedException { ThreadImp threadImp = new ThreadImp(); Thread thread1 = new Thread(threadImp); thread1.start(); } } class ThreadImp extends Thread { public voidrun() { for (int i = 0; i < 10; i++) { System.out.println("StartThread-" + (i + 1) + ":" + new SimpleDateFormat("yyyy/MM/dd hh:mm:ss:Ms") .format(new Date())); System.out.println("hello world");try { sleep(10000); } catch (InterruptedException e) { e.printStackTrace(); } } } }
每隔10秒鐘打印一個“Helloworld”