Given:
public class PingPong implements Runnable {
synchronized void hit(long n) {
for (int i = 1; i < 3; i++)
System.out.print(n + “-” + i + ” “);
}
public static void main(String[] args) {
new Thread(new PingPong()).start();
new Thread(new PingPong()).start();
}
public void run() {
hit(Thread.currentThread().getId());
}
}
Which two statements are true? (Choose two.)
A.
The output could be 8-1 7-2 8-2 7-1
B.
The output could be 7-1 7-2 8-1 6-1
C.
The output could be 8-1 7-1 7-2 8-2
D.
The output could be 8-1 8-2 7-1 7-2
Explanation:
C & D