阅读下列程序?
public class J_Test implements Runnable{
private int x;
private int y;
public static void main(String args[]) {
J_Test t=new J_Test();
(new Thread(t)).start(); //第6行
(new Thread(t)).start(); //第7行
}
public synchronized void run() {
for(;;) {
x++; //第11行
y++;
System.out.println("x="+x+",y="+y);
}
}
}
该程序的执行结果是?
A 在第11行会引起编译错误
B 在第6、7行会引起编译错误
C 程序可能输出x、y不相同的数对,如“x=2,y=1”
D 程序输出递增重复的x、y数对,如“x=1,y=1”、“x=2,y=2”、……
public class J_Test implements Runnable{
private int x;
private int y;
public static void main(String args[]) {
J_Test t=new J_Test();
(new Thread(t)).start(); //第6行
(new Thread(t)).start(); //第7行
}
public synchronized void run() {
for(;;) {
x++; //第11行
y++;
System.out.println("x="+x+",y="+y);
}
}
}
该程序的执行结果是?
A 在第11行会引起编译错误
B 在第6、7行会引起编译错误
C 程序可能输出x、y不相同的数对,如“x=2,y=1”
D 程序输出递增重复的x、y数对,如“x=1,y=1”、“x=2,y=2”、……