




下载本文档
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
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期限已过却未签订正式合同
- 人力入股机制合同标准文本
- dm制作合同范例
- 临沂国际旅行社合同范例
- 单项止回阀采购合同范例
- 企业员工合作合同范例
- 农具销售加工合同范例
- 公司劳务费合同标准文本
- DB14-T 2952-2023 食品小作坊、小经营店、小摊点落实食品安全主体责任工作指南
- GB/T 44438-2024家具床垫功能特性测试方法
- 品质提升计划改善报告课件
- 上海高考化学考纲知识点版
- LYT 2085-2013 森林火灾损失评估技术规范
- 初中九年级化学酸碱盐练习题
- 员工反腐败与合规培训制度
- 中国绝经管理与绝经激素治疗指南(2023版)解读
- 《跟上兔子》绘本五年级第1季A-Magic-Card
- NB∕T 47020~47027-2012 压力容器法兰
- 业主授权租户安装充电桩委托书
评论
0/150
提交评论