当前位置:SCJP程序员认证考试题库

问题:

[单选]

public class X implements Runnable { 
private int x; 
private int y; 
public static void main(String [] args) { 
X that = new X(); 
(new Thread( that )).start(); 
(new Thread( that )).start(); 
} 
public void run() { 
for (;;) { 
synchronized (this) { 
x++; 
y++; 
} 
System.out.println(Thread.currentThread().getName() + 
“x = “ + x + “, y = “ + y); 
} 
} 
}  
What is the result?()  

A .  Compilation fails.
B .  The program prints pairs of values for x and y that might not always be the same on the same line (for example, “x = 2, y = 1”).
C .  The program prints pairs of values for x and y that are always the same on the same line (for example, “x = 1, y = 1”). In addition, each value appears only once (for example, “x = 1, y = 1” followed by “x = 2, y = 2”). The thread name at the start of the line shows that both threads are executing concurrently.
D .  The program prints pairs of values for x and y that are always the same on the same line (for example, “x = 1, y = 1”). In addition, each value appears only once (for example, “x = 1, y = 1” followed by “x = 2, y = 2”). The thread name at the start of the line shows that only a single thread is actually executing.

幼儿园的一日生活包括睡眠、()、进餐、饮水、()、入园、离园。 学前儿童体育的基本动作有走、跑、()、钻爬、投、掷、()。 效应 程控交换机分机回路电阻值(用户摘机状态)应不大于多少?() 1500Ω。 1800Ω。 1600Ω。 1900&Omega。 以下关于SEO中META标签的描述错误的是?() META标签用来描述一个HTML网页文档的属性,例如作者、日期和时间、网页描述、关键词、页面刷新等。 META标签是HTML标记HEAD区的一个关键标签,它位于HTML文档的head和title之间。 在一段HTML代码中,META标签是独立存在的。 Meta标签是用来描述网页属性的一种语言,标准的Meta标签可以便于搜索引擎排序,提高网站权重和排名。

public class X implements Runnable { 
private int x; 
private int y; 
public static void main(String [] args) { 
X that = new X(); 
(new Thread( that )).start(); 
(new Thread( that )).start(); 
} 
public void run() { 
for (;;) { 
synchronized (this) { 
x++; 
y++; 
} 
System.out.println(Thread.currentThread().getName() + 
“x = “ + x + “, y = “ + y); 
} 
} 
}  
What is the result?()  

参考答案:

  参考解析

本题暂无解析

在线 客服