下载本文档
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、iJava 关于线程的面试题(英文)问题:Java关于线程的面试题(英文)回答:1.Do I need to use synchronizedon setValue(int) Itdepe nds whether the method affects method local variables,class static or in sta nee variables. If on ly method local variables are changed, the value is said to be confined by the method and is not prone toth
2、read ing issues.2.Do I need to use synchronizedon setValue(int) Itdepe nds whether the method affects method local variables,class static or in sta nee variables. If on ly method local variables are changed, the value is said to be confined by the method and is not prone tothread ing issues.3. What
3、is the Swi ngUtilities.i nvokeLater(Ru nn able) method forThe static utility method inv okeLater(R unn able) isintended to execute a new runnable thread from a Swing applicati onwithout disturb ing the no rmal seque nee of eve nt dispatchi ngfromthe Graphical User In terface (GUI). Themethod places
4、the runnable object in the queue of Abstract Win dow ingToolkit (AWT) eve nts that are due to be processed and returnsimmediately. The runnable objects run() method2is only called when it reaches the front of the queue. The deferred effectof the inv okeLater(R unn able) method en sures that any n ec
5、essaryupdates to the user in terface can occur immediately, and the runn ablework will beg in as soon as those high priority events are dealt with. Theinvoke later method might be used to start work in resp onse to a butt onclick that also requires a significantchange to the userin terface,perhaps t
6、o restrict otheractivities, whiletherunn able thread executes.4. What is the volatile modifier for The volatile modifier isused to ide ntifyvariables whose values should not beoptimized by the Java Virtual Machine, by caching the value for example.The volatile modifier is typically used for variable
7、s that may be accessedor modified by nu merous in depe ndent threads and signifies that thevalue may change withoutsyn chr oni zatio n.5. Which class is the wait() method defi ned in The wait()method is defined in the Object class, which is the ultimate superclass ofall others. So the Thread class a
8、nd any Runn able implementationinherit this method from Object. The wait()method is normally called on an object in a multi-threaded program toallow other threads to run. The method should should only be called by athread that has own ership of the objects monitor, which usually means3it is in a syn
9、chronized method or stateme nt block.6. Which class is the wait() method definedin I getin compatible retur n type for my threads getState( ) method!It sounds like your application was built for a Java software developmentkit before Java 1.5. The Java API Thread class method getState() was introduce
10、d in vers ion 1.5. Your thread method has the same name butdifferent return type. The compiler assumes your application code isattempting to override the API method with a differe nt return type, whichis not allowed, hence the compilati on error.7. What is a working thread A working thread, more com
11、 mon lyknown as a worker thread is the key part of a desig n patter n thatallocates one thread to execute one task.Whe n the task is complete, the thread may retur n to a thread pool forlater use. In this scheme a thread may execute arbitrary tasks, which arepassed in the form of a Runnable method a
12、rgume nt, typically execute(Runn able). The runn able tasks are usually stored in a queue until a threadhost is available to run them. The worker thread design pattern is usuallyused to han dle many con curre nt tasks where it is not importa nt whichfini shes first and no sin gle task n eeds to be c
13、oord inated with another.The task queue controls how many threads run con curre ntly to improvethe overall performa nee of the system. However, a worker threadframework requires relatively complex program ming to set up, so should4not be used where simpler threadi ng tech niq ues can achieve similar
14、results.8. What is a gree n thread A gree n thread refers to a modeof operation for the Java Virtual Machine (JVM) in which all code isexecuted in a single operating system thread. If the Java program hasany con curre nt threads, the JVM man ages multi-threadi ng in ternallyrather tha n using other
15、operat ingsystem threads. There is a sig ni fica nt process ing overhead for the JVMto keep track of thread states and swap between them, so green threadmode has been deprecated and removed from more recent Javaimplementations.CurrentJVM implementationsmake more efficient use of nativeoperati ng sys
16、tem threads.9. What are native operating system threads Nativeoperati ng system threads are those provided by the computer operatingsystem that plays host to a Java application,be itWin dows,Mac or GNU/L inux.Operat ingsystem threadsenable computers to run many programs simultaneouslyonthe same cen tral process ing unit (CPU) without clashi ng over the use ofsystem reso
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 2026年厨房设计服务合同
- 2025年江苏省启东市委组织部引进国企专业化人才备考题库及答案详解一套
- 2025年中国兵器工业集团航空弹药研究院有限公司公开招聘安全总监备考题库及一套参考答案详解
- 2025年云南大学附属中学星耀学校招聘备考题库及一套答案详解
- 云南昭通检察系统招聘考试真题2024
- 2025年新疆兵团第九师白杨市公安局面向社会招录警务辅助人员30人备考题库及1套参考答案详解
- 2025年福清市人民法院关于公开招聘劳务派遣人员的备考题库及答案详解1套
- 2025年厦门银行南平分行招聘备考题库及一套答案详解
- 2025广东佛山市顺德区杏坛中心小学后勤服务人员招聘1人考试核心题库及答案解析
- 2025青海西宁市艺术实验中学招聘2人备考核心试题附答案解析
- 小寒节气科普讲解
- 杂交瘤细胞的制备过程
- 2025年福建省综合性评标专家库评标专家考试练习题及答案一
- 婴儿急性支气管肺炎业务查房
- 智研咨询发布:运动相机行业市场运行态势、进出口贸易及发展趋势预测报告
- 团队意识的培训课件
- 光伏设备行业深度报告:叠层钙钛矿从0到1超越β-基于技术、设备及投资视角
- 智能门锁安装与维护手册及常见问题处理
- 抖音干货直播课件
- 学校消防标识化管理制度
- 2024年江苏省南京市中考英语试卷真题(含答案)
评论
0/150
提交评论