please help analyse the return value from getId()
6) Given:
5. public class Lockdown implements Runnable {
6. public static void main(
String[] args) {
7. new
Thread(new Lockdown())start();
8. new Thread(new Lockdown())start();
9. }
10. public void run() { locked(Thread.currentThread()getId()); }
11. synchronized void locked(long id) {
12. System.out.print(id + "a ");
13. System.out.print(id + "b ");
14. }
15. }
What is true about possible sets of output from this code?
a) Set 6a 7a 7b 8a and set 7a 7b 8a 8b are both possible.
b) Set 7a 7b 8a 8b and set 6a 7a 6b 7b are both possible. (*)
c) It could be set 7a 7b 8a 8b but set 6a 7a 6b 7b is NOT possible.
d) It could be set 7a 8a 7b 8b but set 6a 6b 7a 7b is NOT possible.
REFERENCE:
JLS 3.0
Option B is correct. Two different Lockdown objects are using the locked() method