Java关于线程的面试题(英文)_第1页
Java关于线程的面试题(英文)_第2页
Java关于线程的面试题(英文)_第3页
Java关于线程的面试题(英文)_第4页
Java关于线程的面试题(英文)_第5页
全文预览已结束

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

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. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论