皮皮学,免费搜题
登录
logo - 刷刷题
搜题
【简答题】
案例5-2实现Runnable接口创建多线程 一、案例描述 1、考核知识点 编 号:00105003 名 称:实现Runnable接口创建多线程 2、练习目标 掌握如何通过实现Runnable接口方式创建多线程。 掌握如何使用Thread类的有参构造方法创建Thread对象。 3、需求分析 在Java中只支持单继承,因此通过继承Thread类创建线一定的局限性,这时可以使用另一种方式,即实现Runnable接口来创建线程。通过这种方式需要在Thread(Runnable target)的构造方法中,传递一个实现了Runnable接口的实例对象。接下来在案例中将通过实现Runnable接口方式创建线程,并实现多线程分别打印0~99的数字的功能。 4、设计思路(实现原理) 1)自定义一个类Demo,使其实现Runnable接口。 2)在Demo类中覆写run()方法,在方法编写一个for循环,循环体内打印:当前线程名称:+当前循环次数。 3)编写测试类Example02,在Example02类的main()方法中,创建一个Demo对象,利用Thread(Runnable target)构造方法创建2个线程对象,分别命名为“蜘蛛侠”和“钢铁侠”,并执行线程对象的start()方法,同时编写for循环,循环内打印“main:”+当前循环次数。
手机使用
分享
复制链接
新浪微博
分享QQ
微信扫一扫
微信内点击右上角“…”即可分享
反馈
参考答案:
举一反三
【单选题】Several (people) in the crowd seemed (as) they were fighting (for) a (ticket).
A.
people
B.
as
C.
for
D.
ticket
【单选题】矩阵制组织形式的采用容易破坏管理的
A.
分工原则
B.
权责一致原则
C.
跳板原则
D.
统一指挥原则
【单选题】It is implied in the last sentence that______.
A.
many scientific areas stop making breakthroughs for lack of effective data collection
B.
scientific research still makes progress without large-scale survey data
C.
the progress of knowledge depends on achievements made by all areas of science together
D.
scientific research has made little progress before the widespread adoption of the Internet
【单选题】“It was several years before other sports were added.”Which of the following means the same?
A.
Before several years passed,other sports were added.
B.
Other sports were not added until several years later.
C.
Several years passed after other sports were added.
【单选题】Several people were missing during the storm.
A.
Right
B.
Wrong
C.
Not mentioned
【单选题】矩阵制组织形式的采用容易破坏管理的
A.
统一指挥原则
B.
权责一致原则
C.
跳板原则
D.
分工原则
【单选题】A2 题型 27岁女,第一胎38周临产,因反复的无痛性阴道出血,诊断为前置胎盘,禁止做的检查是
A.
肛门检查
B.
大、小便常规
C.
B型超声
D.
血常规
E.
腹部检查
【单选题】The board of trustees agreed to the plan ______,but there were several details they didn't like.
A.
in principle
B.
in practice
C.
in essence
D.
in theory
【单选题】[ ] 下列氨基酸中哪个在生理pH下即可做酸又可做碱?
A.
缬氨酸
B.
组氨酸
C.
异亮氨酸
D.
色氨酸
【单选题】. Great ____have been made in the field of computer science in the past decades.
A.
progress
B.
breakthroughs
C.
mistakes
D.
assessments
相关题目:
参考解析:
知识点:
题目纠错 0
发布
创建自己的小题库 - 刷刷题