多选题 Given:
1. class Locker extends Thread {
2. private static Thread t;
3. public void run() {
4. if (Thread.currentThread() == t) {
5. System.out.print ("1 ");
6. synchronized(t) {doSleep(2000); }
7. System.out.print("2 ");
8. } else {
9. System.out.print ("3 ");
10. synchronized(t) {doSleep(1000); }
11. System.out.print("4 ");
12. }
13. }
14. private void doSleep(long delay) {
15. try {Thread.sleep (delay); } catch(InterruptedException ie) { ; }
16. }
17. public static void main (String args[]) {
18. t = new Locker();
19. t.start();
20. new Locker() .start();
21. } }
Assuming that sleep() sleeps for about the amount of time specified in its argument, and that all other code runs almost instantly, which are true? (Choose all that apply.)
【正确答案】 D、E、F、G
【答案解析】