Ex 05 - Concurrent locking exercise

Moderator: Concepts and Technologies for DS and BDP

Benutzeravatar
abhijitsingh
Neuling
Neuling
Beiträge: 2
Registriert: 18. Mai 2016 21:53

Ex 05 - Concurrent locking exercise

Beitrag 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.

JLP
Moderator
Moderator
Beiträge: 35
Registriert: 19. Apr 2010 15:45

Re: Ex 05 - Concurrent locking exercise

Beitrag 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.

Benutzeravatar
AizazZaidee
BASIC-Programmierer
BASIC-Programmierer
Beiträge: 106
Registriert: 20. Apr 2016 22:49

Re: Ex 05 - Concurrent locking exercise

Beitrag von AizazZaidee »

Is there any specific reason to acquire locks in same order? maybe any race condition. Can you please explain further.

Thanks,
AZ

Antworten

Zurück zu „Archiv“