[concurrency-interest] Backport limitations
dawidk at mathcs.emory.edu
Tue May 2 22:39:02 EDT 2006
David Holmes wrote:
>> It is the latter (dev resources), plus it seemed low priority comparing
>> to other things. I didn't have time to sit and analyze how the j.u.c.
>> implementation avoids the risk of deadlock / starvation, which I suppose
>> it must do at least for fair semaphores.
> j.u.c doesn't do anything special with this. What deadlock/starvation risks
> where you thinking of?
Well, the same as in dining philosophers scenario. Say my semaphore has
10 permits. I have 50 threads competing. 49 of them always acquire then
release a single permit, and the 50th thread attempts to acquire 10
permits at once. Then, if implemented that no permits are "grabbed"
until all of them can be acquired, the 50th thread runs a risk of being
On the other hand, with greedy implementation (i.e. grab all that you
can until you get as many as you need), if I have two threads both
trying to get 8 permits (out of 10), they may get stuck after getting,
say, 5 each.
More information about the Concurrency-interest