Determining locking order

  • 32
  • Locked
Implement the logic of the isLockOrderNormal method, which should determine: whether the order of the synchronized blocks in the someMethodWithSynchronizedBlocks method matches the order of the arguments passed to it. If o1 is synchronized first and then o2, the method should return true.
You can't complete this task, because you're not signed in.
Comments (4)
  • Popular
  • New
  • Old
You must be signed in to leave a comment
Level 41 , Warsaw, Poland
29 April 2021, 19:28
I just wanna let you all know that i love this task. It makes you learn so much. Everything got sorted out.
Level 30 , Karlsruhe, Germany
7 August 2020, 11:59
@CodeGym: I think here's another typo in task requirement #2. It should be "[...] synchronizes first using the o2 object and then o1." Otherwise the method isLockOrderNormal() would have to return 'true' and 'false' at the same time, what is obviously impossible.
Level 41
10 August 2020, 06:19
Thanks, we'll fix it
Tony Roy
Level 41 , Victorville, United States
26 April 2020, 21:01
The second requirement is reversed (but the initial statement is clear). More importantly (for me) it is obvious from the code that someMethodWithSynchronizedBlocks synchronizes in the same order as its parameters. So it may seem that there is no question to be answered. But we are to imagine that obj1 and obj2 on lines 13 and 14 are "shuffled" behind our backs. Then, without peeking at the resultant code, isLockedOrderNormal discovers how they are set.