Given: 1. public class X i m pl e m ents Runnable { 2. private int x; 3. private int y; 4. 5. public static void m ain(String [] args) { 6. X that = new X(); 7. (new Thread( t h at )). s tart(); 8. (new Thread( t h at )). s tart(); 9. } 10. 11. public void run() { 12. for (;;) { 13. synchronized (this) { 14. x++; 15. y++; 16. } 17. Syste m .out.println(Thread.current T hread().get N a m e() + "x = " + x + ", y = " + y); 18. } 19 } 20 } W hat is the result?
B.
The program prints pairs of values for x and y that m i ght not always be the sa m e on the sa m e line (for exa m ple, "x = 2, y = 1").
C.
The program prints pairs of values for x and y that are always the sa m e on the sa m e line (for example, "x = 1, y = 1").In addition, each val u e appears only once ( f or e x a m ple, "x = 1, y = 1" followed by "x = 2, y = 2").The thread n a m e at the start of the li n e shows that both threa d s are e x ecuting concurrently.
D.
The program prints pairs of values for x and y that are always the sa m e on the sa m e line (for example, "x = 1, y = 1").In addition, each val u e appears only once ( f or e x a m ple, "x = 1, y = 1" followed by "x = 2, y = 2").The thread n a m e at the start of the li n e s hows that only a single thread is actually executing.