• 2022-06-05
    5.1 在(1)~(3)处填上适当的语句,使程序能正常运行。 class MyThread implements Runable { (1) { while(true){System.out.print("hello"); try { (2) //休眠1秒钟 } catch (InterruptedException e) { e.printStackTrace(); } }}} public class Demo{ public static void main(String []s){ MyThread thread1= (3) //声明创建对象thread1 Thread thread = new Thread(thread1,"线程1") thread.start(); //通过对象thread启动线程 }}