问个Thread 的问题,java certificate里的# Java - 爪哇娇娃
o*a
1 楼
1. public class X implements Runnable{
2. private int x;
3. private int y;
4.
5. public static void main(String[]args){
6. X that = new X();
7. (new Thread(that)).start();
8. (new Thread(that)).start();
9. }
10.
11. public void run(){
12. for (;;){
13. x++;
14. y++;
15. System.out.printIn(“x=” + x + “, y = ” + y); 16. }
17. }
18.}
What is the result?
A. Errors at lines 7 and 8 cause compilation to fail.
B. The program prints pairs of values for x and y that might not always be the
same on the sa
2. private int x;
3. private int y;
4.
5. public static void main(String[]args){
6. X that = new X();
7. (new Thread(that)).start();
8. (new Thread(that)).start();
9. }
10.
11. public void run(){
12. for (;;){
13. x++;
14. y++;
15. System.out.printIn(“x=” + x + “, y = ” + y); 16. }
17. }
18.}
What is the result?
A. Errors at lines 7 and 8 cause compilation to fail.
B. The program prints pairs of values for x and y that might not always be the
same on the sa