esta é boa para testar uns conceitos…
Consider the following code:
[code]
public class Test extends Thread {
static Object obj = new Object();
static int x, y;
public void run() {
synchronized (obj) {
for (;;) {
x++;
y++;
System.out.println(x + " " + y);
}
}
}
public static void main(String[] args) {
new Test().start();
new Test().start();
}
}[/code]
What will the above code print?
Select 1 correct option.
A - It will keep on printin same values for x and y incrementing by 1 on each line.
B - It will keep on printin same values for x and y but they may be incrementing by more than 1 on each line.
C - It may print different values for x and y but both the values will be incrementing by 1 on each line.
D - You cannot say anything about the values.