Atomic updates

cal callumenator at gmail.com
Tue Jan 22 10:10:26 PST 2013


On Tuesday, 22 January 2013 at 09:47:25 UTC, monarch_dodra wrote:
> Avoids deadlock.
>
> imagine 2 threads:
> a: from 2 to 5.
> b: from 5 to 2.
>
> If both threads acquire their first lock, then you have a dead 
> lock, and your program is basically dead.
>
> By always locking low first, you avoid the deadlock in a rather 
> simple but elegant way.

Ah neat. And what about the case from = to? Why doesn' that 
deadlock in this code? (Concurrency is rather new to me)


More information about the Digitalmars-d-learn mailing list