题目详情
当前位置:首页 > 职业培训考试
题目详情:
发布时间:2024-01-01 00:07:22

[填空题]通过继承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( ) + "已结束");

更多"通过继承Thread创建线程,在主控程序中同时运行两个线程Thread"的相关试题:

[填空题]通过继承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( ) + "已结束"); }
[填空题]在多线程程序设计中,如果采用继承Thread类的方式创建线程,则需要重写Thread类的______( )方法。


[简答题]创建线程对象,要传递代码与数据,而传递代码与数据有两种方法,一是通过继承Thread类,二是向Thread类传递一个Runnable对象。请在下面程序的每条横线处填写一个语句,使程序的功能完整。
注意:请勿改动main( )主方法和其他已有的语句内容,仅在横线处填入适当的语句。
源程序文件清单如下;
public class TestThread

public static void main(String args[ ])

MyThread t=new MyThread( );
______;


class MyThread ______ Thread

______

for(int i=0;i<10;i++)

System.out.println(" "+i);



[填空题]提供线程体的特定对象是在创建线程时指定的;创建线程对象是通过调用 【6】 类的构造方法实现的。
[填空题]当使用Thread t=new Thread(r)创建一个线程时,表达式:r instranceof Thread的值是______。
[填空题]当使用Thread t=new Thread(r)创建一个线程时,表达式:r instanceof Thread的值是______。

我来回答:

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

订单号:

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