[填空题] 下列程序创建了一个线程并运行,请填空,使程序完整。 public class ThreadTest public static void ma
2021-07-20
[填空题] 下列程序创建了一个线程并运行,请填空,使程序完整。
public class ThreadTest
public static void main(String args[])
Hello h=new Hello();
______;
t.start();
class Hello implements Runnable
int i;
public void run()
while(true)
System.out.println("Hello"+i++);
if(i==5) break;
正确答案:Thread t=new Thread(h)
参考解析:本题考查线程的概念。线程是比较抽象的概念,但属于考试重点内容。题目程序的功能是按要求实现输出,通过实现Runnable接口来创建线程。 Runable接口的定义为: public interface Runnable{void run();
词条内容仅供参考,如果您需要解决具体问题
(尤其在法律、医学等领域),建议您咨询相关领域专业人士。
