题目内容
(请给出正确答案)
[主观题]
通过继承Thread创建线程,在主控程序中同时运行两个线程Thread1和Thread2。请在下面横线处填入代码
完成此程序。 public class ThreadTest { public static void main(String args[]) { new TestThread("Threadl").start(); 【 】 } } class TestThread extends Thread() { public TestThread(String str) { super (str); } public void run() { for(int i = 0; i<5; i++) { System.out.println(i + ....+ getName() + "在运行"); try { Sleep(1000); }catch(InerruptedException e) {} } System.out.println(getName() + "已结束"); }
答案
查看答案