Mais uma de Threads

esta é boa para testar uns conceitos… :smiley:

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.

eu acho que é a A, já que as duas variáveis são incrementadas no mesmo loop… é isso?

Tambem acho que eh a letra A, pois o primeiro thread a ser startad nao vai perder o foco nunca. (usar teclado sem acento eh horrivel)

ambos acertaram :smiley: