Seite 1 von 1

Ex 05 - Concurrent locking exercise

Verfasst: 9. Jun 2016 19:55
von abhijitsingh
I am not able to understand the provided solution for this exercise.
In the first part, how using the stream is providing the concurrent thread execution safety.
In the second part after executing the lock function, the size of the list becomes zero. After that, all code to check if a lock is acquired correctly makes no sense.

Re: Ex 05 - Concurrent locking exercise

Verfasst: 14. Jun 2016 10:53
von JLP
abhijitsingh hat geschrieben:In the first part, how using the stream is providing the concurrent thread execution safety.
It is not the stream itself which guarantees deadlock-freedom but the fact that the stream is sorted, i.e., you always acquire the locks in the same order.
abhijitsingh hat geschrieben:In the second part after executing the lock function, the size of the list becomes zero. After that, all code to check if a lock is acquired correctly makes no sense.
Good catch :-) Indeed, the test case failed to discover faulty code in some situations. This is fixed now in the code provided on the course website. The solution is still correct, though.

Re: Ex 05 - Concurrent locking exercise

Verfasst: 1. Jul 2016 12:11
von AizazZaidee
Is there any specific reason to acquire locks in same order? maybe any race condition. Can you please explain further.

Thanks,
AZ