未分类题

清阅读下面程序,说明该程序创建线程使用的方法是( )。 publicclassThreadTest { publicstaticvoidmain(Stringargs[]) { Threadt1=newThread(newHolloWorld()); Threadt2=newThread(newHolloWorld()); t1.start(); t2.start(); } } classHolloWorldimplementsRunnable { inti; publicvoidrun() { while(true) { System.out.println('HolloWorld'+i++); if(i==5)break; } } }
A.继承Thread类
B.实现Runnable接口
C.t1.start()
D.t2.stan()

A.start();
B.start();
C.out.println('HolloWorld'+i++);
D.继承Thread类
B.实现Runnable接口
C.t1.start()

【参考答案】

B
解析: 本题考查线程的创建。在Java中,创建线程有两种方法:①通过实现Runnable接口创建线程。Ru......

(↓↓↓ 点击下方‘点击查看答案’看完整答案 ↓↓↓)