当前位置:会计基础题库>会计基础综合练习题库

问题:

[单选]

class Computation extends Thread { 
private int num; 
private boolean isComplete; 
private int result; 
public Computation(int num) { this.num = num; } 
public synchronized void run() { 
result = num * 2; 
isComplete = true; 
notify(); 
} 
public synchronized int getResult() { 
while (!isComplete) { 
try { 
wait(); 
} catch (InterruptedException e) { } 
} 
return result; 
} 
public static void main(String[] args) { 
Computation[] computations = new Computation [4]; 
for (int i = 0; i < computations.length; i++) { 
computations[i] = new Computation(i); 
computations[i] .start(); 
} 
for (Computation c : computations) 
System.out.print(c.getResult() +“ “); 
} 
} 
What is the result?() 

A .  The code will deadlock.
B .  The code may run with no output.
C .  An exception is thrown at runtime.
D .  The code may run with output “0 6”.
E .  The code may run with output “2 0 6 4‟.
F .  The code may ruin with output “0 2 4 6”.

唐代有一位诗人贬谪江州后,寄情山水诗酒之间,继而皈依佛教,以“香山居士”自许。这位诗人是() 王维。 柳宗元。 杜牧。 白居易。 在水利水电工程注册建造师执业工程规模标准中,堤防工程的执业工程规模标准根据其()确定。 A.等别 。 B.级别 。 C.投资额 。 D.保护面积。 通过分析重要的学前教育的文献、文件资料来了解外国学前教育情况的一种方法,称为() 最新一期全球超级计算机500强(TOP500)榜单11月14日在美国盐湖城公布,使用中国自主芯片制造的()再次问鼎冠军。这是世界上首台运行速度超过十亿亿次的超级计算机,中国连续4年占据全球超算排行榜的最高席位。 “天河一号”。 “天河二号”。 “图灵”。 “神威太湖之光&rdquo。 每服务器模式

class Computation extends Thread { 
private int num; 
private boolean isComplete; 
private int result; 
public Computation(int num) { this.num = num; } 
public synchronized void run() { 
result = num * 2; 
isComplete = true; 
notify(); 
} 
public synchronized int getResult() { 
while (!isComplete) { 
try { 
wait(); 
} catch (InterruptedException e) { } 
} 
return result; 
} 
public static void main(String[] args) { 
Computation[] computations = new Computation [4]; 
for (int i = 0; i < computations.length; i++) { 
computations[i] = new Computation(i); 
computations[i] .start(); 
} 
for (Computation c : computations) 
System.out.print(c.getResult() +“ “); 
} 
} 
What is the result?() 

参考答案:

  参考解析

本题暂无解析

在线 客服