上一篇
實現Runnable接口的類必須使用Thread類的實例才能創建線程
最後通過Thread類的start方法建立線程
下面的代碼演示了如何使用Runnable接口來創建線程
package mythread;
public class MyRunnable implements Runnable
{
public void run()
{
System
}
public static void main(String[] args)
{
MyRunnable t
MyRunnable t
Thread thread
Thread thread
thread
thread
thread
}
}
上面代碼的運行結果如下
MyThread
MyThread
From:http://tw.wingwit.com/Article/program/Java/gj/201311/27466.html