下载本文档
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
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广西百色市西林县民政局招聘编外聘用人员(补招聘)1人参考考试试题附答案解析
- 化妆品企业生产制度
- 生产部门动态管理制度
- 2026湖南长沙市雨花区砂子塘魅力第二小学春季教师招聘参考考试题库附答案解析
- 文具店安全生产制度
- 预制菜生产规章制度
- 生产失信行为惩戒制度
- 2024水电工程陆生野生动物生境保护设计规范
- 风电场安全警示教育培训课件
- 神经细胞器膜脂质调控机制-洞察及研究
- 加油站职业卫生安全培训课件
- 仁爱科普版(2024)七年级上册英语全册教案(单元整体教学设计)
- 高速公路路基施工组织方案
- 药物中毒指南
- (2025年标准)强奸私了协议书
- 2025年山东省威海市环翠区数学六年级第一学期期末考试试题含解析
- 山西省建筑工程施工安全管理标准
- 颅内占位性的病变护理查房讲课件
评论
0/150
提交评论