更多"下列程序创建了一个线程并运行,请填空,使程序完整。 public c"的相关试题:
[填空题]下面程序创建了一个线程并运行,请填空,使程序完整。
public class ThreadTest
public static void main (String[] args)
Hello h=Hew Hello ( );
【8】
t.start ( );
class Hello implements Runnable
int i;
public void run ( )
while(true)
System.out.println("Hello" +i++);
if(i==5) break;
[填空题]下列程序创建了一个线程并运行,请填空,使程序完整。
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;
[单项选择]阅读下面程序:
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. sleep()
B. yield()
C. interrupt()
D. start()
[单项选择]请阅读下面程序
public class ThreadTest
public static void inain(String args[]) throws Exception
int i=0;
Hello t=new Hello( );
______;
while(true)
System.out.printIn ("Good Morning"+j++);
if(i==2&&LisAlive( ))
System.out.printIn("Main waiting for Hello!");
T.join( );//等待t运行结束
if(i==5)break;
class Hello extends Thread
int i ;
public void run( )
while(true)
System.out.printIn("Hello"+i++);
if(i==5) break;
为使该程序正确执行,下画线处的语句应是______。
A. sleep()
B. yield()
C. interrupt()
D. start()
[单项选择]请阅读下面程序
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. sleep()
B. yield()
C. interrupt()
D. start()
[单项选择]阅读下面程序
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)
System.out.println("Hello"+i++);
it(i==5) break;
此程序创建线程所使用的方法是
A. 继承Thread类
B. 实现Runnable接口
C. t1.start()
D. t2.start()
[单项选择]请阅读下面程序
public class ThreadTest{
public static void main(String args[])throws Ex-
ception{
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 Hel-
lo!");
t.join( );//等待t运行结束
}
if(i= =5)break;}
}
}
class Hello extends Thread{
int l;
public void run( ){
while(true)(
System.Out.println("Hell0"+i++);
if(i= =5)break;)))
为使该程序正确执行,下画线处的语句应是( )。
A. t.sleep()
B. t.yield()
C. t.interrupt()
D. t.start()
[单项选择]阅读下列程序:
class ThreadTest extends Thread
public static void main(String[]args)
Thread t=new Thread(this);
t.start( );
public void run( )
System.out.print("A thread test.");
对该程序而言,正确结论是 ( )
A. 该程序能够通过编译并打印输出“A thread test.”
B. 该程序能够通过编译,但运行时将不调用ThreadTest类中的run()方法,因此不产生任何输出
C. 该程序存在编译错误,因为在main()方法中不能使用this指针
D. 上述选项都不正确
[单项选择]阅读下面程序 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) { System.out.println("Hello"+i++); it(i==5) break; } } } 此程序创建线程所使用的方法是
A. 继承Thread类
B. 实现Runnable接口
C. t1.start()
D. t2.start()
[填空题]下列程序创建了一个线程并运行,请填空,使程序完整。
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;
}
}
}
[填空题]下列程序创建了一个线程并运行,请填空,使程序完整。
public class ThreadTest
public static void main(String args[])
Hello h=new Hello( );
【12】 ;
t.start( );
class Hello implements Runnable
int i;
public void run( )
while(tree)
System.out.println("Hello" +i++);
if(i==5) break;