- package bbs.istak.org.tw;
- public class Main {
- Main()
- {
-
- show1();
- show2();
-
-
-
- }
- void show1()
- {
- Thread th = new Thread(){
- public void run()
- {
- for( int i=5; i>=1; i--)
- {
- try {
- Thread.sleep(1000);
- } catch (InterruptedException e) {
- }
-
- System.out.println(i+"秒"+Thread.currentThread().getName());
- }
- System.out.println("Time Out!!!");
- System.out.println("執行緒名稱:"+Thread.currentThread().getName());
- }
-
- void show2 ()
- {
- Thread th = new Thread(){
- public void run()
- {
- for( int i=5; i>=1; i--)
- {
- try {
- Thread.sleep(1000);
- } catch (InterruptedException e) {
- }
-
- System.out.println(i+"秒"
- +Thread.currentThread().getName());
- }
- System.out.println("Time Out!!!");
- System.out.println("執行緒名稱:"+Thread.currentThread().getName());
- }
- }
-
- ;
- }
-
- public static void main(String[] args) {
- new Main();
- }
- }
複製代碼 |