[单选题]

阅读下面程序: public class ThreadTest { public static void main(String args[]) throws Exception { int i=0; Hello t=new Hello(); ______; While(true) } System.out.println("Good Morning"+i++); if(i==2&&t.isAlive()) { System.out.println("Main waiting for Hello!"); t.join(); //等待t运行结束 } If(i==5)break:} } } class Hello extends Thread } int i; public void run() while(true) { System.out.println("Hello"+i++): If(i==5)break; } } } 为使该程序正确执行,下画线处的语句应是

A.t.sleep()

B.t.yield()

C.t.interrupt()

D.t.start()

参考答案与解析:

相关试题

请阅读下面程序 public class ThreadTest {public

[单选题]请阅读下面程序 public class ThreadTest { public static void main(String args[]) throws Exception{ int i=0; Hello t=new Hello(); while(true) { System.out.println("Good Moming"+i++); if (i==2 && t.isAlive()) { System. out.println("Main waiting for

  • 查看答案
  • 请阅读下面程序 public class ThreadTest {public

    [单选题]请阅读下面程序 public class ThreadTest { public static void main(String args[]) throws Exception{ int i=0; Hello t=new Hello(); while(true) { System.out.println("Good Moming"+i++); if (i==2 && t.isAlive()) { System. out.println("Main waiting for

  • 查看答案
  • 请阅读下面程序 public class ThreadTest{public s

    [单选题]请阅读下面程序 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) { Sys

  • 查看答案
  • 请阅读下面程序 public class ThreadTest{public s

    [单选题]请阅读下面程序 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) { Sys

  • 查看答案
  • ( 24 )请阅读下面程序public class ThreadTest {pu

    [单选题]( 24 )请阅读下面程序public class ThreadTest {public static void main ( String args[ ]){Thread t1 = new Thread ( new Hello ()):Thread t2 = new Thread ( new Hello ()):t l .start ():t2.start ();}}class Hello implements Runnable {int i ;public void run (){while

  • 查看答案
  • ( 28 )请阅读下面程序public class ThreadTest {pu

    [单选题]( 28 )请阅读下面程序public class ThreadTest {public static void main ( String args[ ]) throws Exception {int i=0;H.ello t = new Hello ();___________;whlle ( true ){System.out.println ( "Good Morning"+i++ ) ;if ( i=2 && t.isAlive ()){System.out.println (

  • 查看答案
  • 阅读下面程序public cmass ThreadTest { public s

    [单选题]阅读下面程序 public cmass 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) { Sys

  • 查看答案
  • 阅读下面程序public class VariableUse { public

    [单选题]阅读下面程序 public class VariableUse { public static void main(String[] arqs) { int a; if(a==8) { int b=9; System.out.println("a="+a); System.out.println("b="+b); } System.out.println("a="+a); System.out.println("b="+b): } } 该程序在编译时的结果是A.变量a未赋值B.第

  • 查看答案
  • 阅读下面程序public class Increment { public st

    [单选题]阅读下面程序 public class Increment { public static void main( String args[] ){ int c; c=5; System.out.println(C) ; System.out.println(c++); System.out.println(C) ; } }A.5 6 6B.5 5 6C.6 7 7D.6 6 6

  • 查看答案
  • 阅读下面程序public class Increment {public sta

    [单选题]阅读下面程序 public class Increment { public static void main( String args[] ){ int c; c=5; System.out.println( c ); System.out.println( c++ ); System.out.println( c ); } )程序运行结果是( )。A.5 6 6B.5 5 6C.6 7 7D.6 6 6

  • 查看答案
  • 阅读下面程序:public class ThreadTest { public