




下载本文档
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
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. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 2025-2030中国骨科植入器材行业市场深度发展趋势与前景展望战略研究报告
- 2025-2030中国骑行安全气囊市场应用规模现状与投资前景战略研究报告
- 2025-2030中国香草市场深度调查与未来前景趋势研究报告
- 2025-2030中国馅料和浇头行业市场发展趋势与前景展望战略研究报告
- 2025-2030中国饲料原料行业市场发展现状及发展趋势与投资前景研究报告
- 2025-2030中国饮料玻璃包装行业市场发展趋势与前景展望战略研究报告
- 2025-2030中国食物储物柜行业市场现状供需分析及投资评估规划分析研究报告
- 2025-2030中国食品级明胶行业市场发展趋势与前景展望战略研究报告
- 化工安全培训内容
- 2025-2030中国面包釉行业市场现状供需分析及投资评估规划分析研究报告
- 宠物犬品种识别-玩赏犬品种(宠物品种)
- YS/T 1025-2015电子薄膜用高纯钨及钨合金溅射靶材
- 《社会主义核心价值观》优秀课件
- 髋关节的解剖-课件
- 幼儿园绘本故事:《十二生肖》 课件
- 一例心肌梗塞患者的病例讨论培训课件
- GB∕T 13171.2-2022 洗衣粉 第2部分:试验方法
- 楷书(课件)课件
- 工程监理部人员分工与职责
- 课程设计 CA6140拨叉说明书
- 成语故事杞人忧天PPT教案
评论
0/150
提交评论