[concurrency-interest] how to use Thread.yield to fix ConcurrentIntArrayList
andy at stagirite.com
Tue Jan 9 18:53:25 EST 2018
Are you saying that my code works on openjdk as is, or should the loops
at the beginning of each of my functions, loop say 20 times, and then if
no progress, do a Thread.sleep? Also Brian O'Neill responded that the
volatile marker to the effectively final "ar" member of MyArray should
be final. Does it really matter in my use case?
On 01/09/2018 12:59 PM, David Holmes wrote:
> The priority-induced deadlock you describe can only occur if you are running under a strict priority-preemptive scheduler (i.e SCHED_FIFO) and even then it depends on the number of processors and the number of always runnable threads and their priority. The OpenJDK is not designed to run in such environments - neither the algorithms in existing j.u.c classes, nor the VM itself. To solve your problem a thread that can't make progress must eventually block to ensure other threads can make progress.
More information about the Concurrency-interest