Java

本类阅读TOP10

·使用MyEclipse开发Struts框架的Hello World!(录像1)
·hibernate配置笔记
·AOP编程入门--Java篇
·linux下Tomcat 5.0.20 与 Apache 2 安装/集成/配置
·在win2003下整合了整合Tomcat5.5+ apache_2.0.53+ mod_jk_2.0.47.dll
·构建Linux下IDE环境--Eclipse篇
·Jsp 连接 mySQL、Oracle 数据库备忘(Windows平台)
·ASP、JSP、PHP 三种技术比较
·Tomcat5.5.9的安装配置
·AWT GUI 设计笔记(二)

分类导航
VC语言Delphi
VB语言ASP
PerlJava
Script数据库
其他语言游戏开发
文件格式网站制作
软件工程.NET开发
Exercise of the Thread(2)

作者:未知 来源:月光软件站 加入时间:2005-2-28 月光软件站

11.Which three are methods of the Object class?(Choose three.)

A.    notify();
B.    notifyAll();
C.    isInterrupted();
D.    synchronized();
E.    interrupt();
F.    wait(long msecs);
G.    sleep(long msecs);
H.    yield();

(A.B.F).  Java Doc


12.Given the following.

1.public class WaitTest{
2.    public static void main(String []args){
3.        System.out.print("1    ");
4.        synchroized(args){
5.            System.out.print("2    ");
6.            try{
7.                args.wait();
8.                }
9.                catch(InterruptedException e){}
10.        }
11.        System.out.print("3    ");
12.    }
13.}

what is the result of trying of compile and run this program?

A.    It fails to compile because the IllegalMonitorStateException of wait() is not dealt with in line 7.

B.    1 2 3

C.    1 3

D.    1 2

E.    At runtime,it throws an IllegalMonitorStateException when trying to wait.

F.    It will fail to compile because it has to be synchronized on the this object.

(D).将打印1和2,但是,因为没有其他线程通告主线程,他们不会返回调用WAIT,所以3不会被打印,程序会冻结在第7行;    A是错误的,因为IllegalMonitorStateException是一个不检测的异常,所以它不会进行明确的处理;    F是错误的,因为任何OBJECT都可以使用synchroized,此外,当运行静态方法时,它不属于这个对象;


相关文章

相关软件