题目详情
当前位置:首页 > 职业培训考试
题目详情:
发布时间:2024-04-08 20:58:01

[单项选择]清阅读下面程序,说明该程序创建线程使用的方法是( )。
publicclassThreadTest

publicstaticvoidmain(Stringargs[])

Threadt1=newThread(newHolloWorld( ));
Threadt2=newThread(newHolloWorld( ));
t1.start( );
t2.start( );


classHolloWorldimplementsRunnable

inti;
publicvoidrun( )

while(true)

System.out.println("HolloWorld"+i++);
if(i==5)break;



A. 继承Thread类
B. 实现Runnable接口
C. t1.start()
D. t2.stan()

更多"清阅读下面程序,说明该程序创建线程使用的方法是( )。 publi"的相关试题:

[单项选择]清阅读下面程序,说明该程序创建线程使用的方法是( )。
publicclassThreadTest

publicstaticvoidmain(Stringargs[])

Threadt1=newThread(newHolloWorld( ));
Threadt2=newThread(newHolloWorld( ));
t1.start( );
t2.start( );


classHolloWorldimplementsRunnable

inti;
publicvoidrun( )

while(true)

System.out.println("HolloWorld"+i++);
if(i==5)break;



A. 继承Thread类
B. 实现Runnable接口
C. t1.start()
D. t2.stan()
[单项选择]请阅读下面程序,说明该程序创建线程使用的方法是( )。   public class ThreadTest   {   public static void main(String args[])   {   Thread tl=new Thread(new HolloWorld( ));   Thread t2=new Thread(new HolloWorld( ));   tl.start( );   t2.Start( );   }   }   class HolloWorld implements Runnable   {   int i;   public void run( )   {   while(true)   {   System.out.println("HolloWorld"+i++);   if(i= =5)break;   }   }   }
A. 继承Thread类
B. 实现Runnable接口
C. tl.start()
D. t2.start()
[填空题]下面程序创建了一个线程并运行,请填空,使程序完整。
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;



[填空题]通过继承Thread创建线程,在主控程序中同时运行两个线程Thread1和Thread2。请在下面横线处填入代码完成此程序。
public class ThreadTest

public static void main(String args[])

new TestThread("Threadl").start( );
【7】


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( ) + "已结束");

[简答题]通过实现Runnable接口创建线程,请在下面横线处填入代码完成此程序。 注意:不改动程序结构,不得增行或删行。 class ThreadTest implements Runnable { Thread thrObj; public static void main(String args[]) { System.out.println("这是一个通过实现接口创建线程的例子"); ThreadTest testObj=new ThreadTest( ); testObj.create( ); } public void create( ) { if(thrObj= =null) { thrObj=new Thread(this,"myThread"); ______ } } public void run( ) { System.out.println("Thread"+throbj.getName( )+":"+"在运行!"); } }
[填空题]通过实现Rmmable接口创建线程,请在下面横线处填写代码完成此程序。 public class ThreadTest { public static void main(String args []) { Thread testObj1 = new Thread (new Hello ( )); Thread testObj2 = new Thread (new Hello ( )); testObj 2.start ( ); } } class Hello implements Runnable { int j; public void run( ) { System.out.println("Hello" + j ++); } }
[简答题]通过实现Runnable接口创建线程,请在下面横线处填入代码完成此程序。
注意:不改动程序结构,不得增行或删行。
class ThreadTest implements Runnable

Thread thrObj;
public static void main(String args[])

System.out.println("这是一个通过实现接口创建线程的例子");
ThreadTest testObj=new ThreadTest( );
testObj.create( );

public void create( )

if(thrObj= =null)

thrObj=new Thread(this,"myThread");
______


public void run( )

System.out.println("Thread"+throbj.getName( )+":"+"在运行!");


[简答题]下面的程序的功能是利用实现Runnable接口的方法来创建线程,并利用它来执行响应的一些操作。最后使得m的执行结果为100。
注意:请勿改动main( )主方法和其他已有的语句内容,仅在下划线处填入适当的语句。
源程序文件代码清单如下:
class ClassName implements Runnable

int n;
______

try

Thread.sleep(2000);
n=100;
catch(Exception e)

public static void main(String args[])

try

ClassName a=new ClassName( );
_____
thread1.start( );
thread1.join( );
int m=a.n;
System.out.println("m="+m);
catch(Exception e)


[填空题]提供线程体的特定对象是在创建线程时指定的;创建线程对象是通过调用 【6】 类的构造方法实现的。
[填空题]下面程序的功能是创建一个显示5个“Hello!”的线程并启动运行。请将程序补充完整。 public class ThreadTest extends Thread {  public static void main(String args[]) {   ThreadTest t=new ______;   t.start( );  }  public void run( ) {   int i=0;   while(true) {    System.out.println("Hello!");    if(i++==4)break;   }  } }
[填空题]下面程序的功能是创建一个显示5个“Hello!”的线程并启动运行。请将程序补充完整。
public class ThreadTest extends Thread
 public static void main(String args[])
  ThreadTest t=new ______;
  t.start( );
 
 public void run( )
  int i=0;
  while(true)
   System.out.println("Hello!");
   if(i++==4)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(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(true)
System.out.println("Hello"+i++);
if(i==5) break;



我来回答:

购买搜题卡查看答案
[会员特权] 开通VIP, 查看 全部题目答案
[会员特权] 享免全部广告特权
推荐91天
¥36.8
¥80元
31天
¥20.8
¥40元
365天
¥88.8
¥188元
请选择支付方式
  • 微信支付
  • 支付宝支付
点击支付即表示同意并接受了《购买须知》
立即支付 系统将自动为您注册账号
请使用微信扫码支付

订单号:

请不要关闭本页面,支付完成后请点击【支付完成】按钮
恭喜您,购买搜题卡成功
重要提示:请拍照或截图保存账号密码!
我要搜题网官网:https://www.woyaosouti.com
我已记住账号密码