单选题 请阅读如下程序。
public class ThreadTest
{
public static void main(String args[])
{
Thread t1 = new Thread(new Hello());
Thread t2 = new Thread(new Hello());
t1.start ();
t2.start();
}
}
class Hello implements Runnable
{
int i;
public void run()
{
While (true)
{
System.out.println("Hello"+i++);
if (i==5)
break;
}
}
}
该程序创建线程使用的方法是______。
  • A.继承Thread类
  • B.实现Runnable接口
  • C.t1.start()
  • D.t2.start()
【正确答案】 B
【答案解析】[解析] 在Java中有两种创建线程的方法,即实现Runnable接口、继承Thread类,本题中Hello类声明语句“class Hello implements Runnable”,表示该类实现了Runnable接口,所以选项B正确。