問題詳情

235.Given: 11. public class PingPong implements Runnable{ 12. synchronized void hit(long n){ 13. for(int i=1; i<3; i++) 14. System.out.print(n + "-" + i + " "); 15. } 16. public static void main(String[] args){ 17. new Thread(new PingPong()).start(); 18. new Thread(new PingPong()).start(); 19. } 20. public void run(){ 21. hit(Thread.currentThread().getId); 22. } 23. } 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

參考答案