多选题 Given:
2. class Grab {
3. static int x = 5;
4. synchronized void adjust(Grab y) {
5. System.out.print(x-- + " ");
6. y.view(y);
7. }
8. synchronized void view(Grab z) {if(x > 0) z.adjust(z); }
9. }
10. public class Grapple implements Runnable {
11. static Thread t1;
12. static Grab g, g2;
13. public void run() {
14. if(Thread.currentThread().getId() == t1.getId()) g.adjust(g2);
15. else g2.view(g);
16. }
17. public static void main(String[] args) {
18. g = new Grab();
19. g2 = new Grab();
20. t1 = new Thread(new Grapple());
21. t1.start();
22. new Thread(new Grapple()).start();
23. } }
Which are true? (Choose all that apply.)
【正确答案】 B、C、F
【答案解析】