Which three will compile and rim without exception? (Choose three.)
A. private synchronized Object o;
B. void go() {
synchronized() { /* code here */ }
}
C. public synchronized void go() { /* code here */ }
D. private synchronized(this) void go() { /* code here */ }
E. void go() {
synchronized(Object.class) { /* code here */ }
}
F. void go() {
Object o = new Object();
synchronized(o) { /* code here */ }
}答案:CEF其实这题不懂出于对体干英语不认识- -rim什么意思?跳出?这题的意思是哪三个会编译成功而且无错误的退出?请结合答案说明下这题哈~感激不尽^_^
A. private synchronized Object o;
B. void go() {
synchronized() { /* code here */ }
}
C. public synchronized void go() { /* code here */ }
D. private synchronized(this) void go() { /* code here */ }
E. void go() {
synchronized(Object.class) { /* code here */ }
}
F. void go() {
Object o = new Object();
synchronized(o) { /* code here */ }
}答案:CEF其实这题不懂出于对体干英语不认识- -rim什么意思?跳出?这题的意思是哪三个会编译成功而且无错误的退出?请结合答案说明下这题哈~感激不尽^_^
Neither javac nor RIM ’s compiler
是一种编译器,用于BlackBerry,掌上电脑
三种答案都是多线程中的同步概念,同步方法和同步块
A中不能用来生命类的对象
B中的用法不正确 synchronized 方法:通过在方法声明中加入 synchronized关键字来声明 synchronized 方法。
D中估计是想应用 synchronized 块
语法如下:
synchronized(syncObject) {
//允许访问控制的代码
}
解释的可能不是很准确!希望你能明白!!