Concurrency Anti-pattern Catalog for Java

Starvation anti-pattern

Problem: This bug occurs when their is a failure to ...allocate CPU time to a thread. This may be due to scheduling policies..." [Lea00]. For example, an unfair lock acquisition scheme might cause a thread never to be scheduled.

Java example of the problem: ...

Context: Trying to use concurrency independent of scheduling policies.

Solution: When available use fairness parameter for concurrent mechanisms like semaphores. This will ensure that no thread can unfairly acquire semaphore permits.

Java example of the solution: ...

References:

[Lea00] D. Lea, Concurrent Programming in Java: Design Principles and Patterns, Second Edition. Addison Wesley, 2000.