[concurrency-interest] ArrayBlockingQueue (and possibly others) not waking on interrupt?

Doug Lea dl at cs.oswego.edu
Wed Dec 3 07:10:24 EST 2014


On 12/01/2014 03:17 PM, Charles Oliver Nutter wrote:
> This logic is being used to emulate fibers (coroutines) in JRuby. A
> fiber belongs to a given thread, and there may be many active fibers
> within a thread, but none of them run concurrently. Every transfer
> into a fiber is an explicit hand-off.

Continuously blocking and unblocking a bunch of threads such
that only one of them is running at any given time is among
the slowest things you can do on a multicore these days, no
matter what synchronization scheme you use. I suspect that
even the slowest of the exception-based coroutine conversion
techniques would be a lot faster. (Googling "java coroutine"
finds some.) Better options should be available if/when JVMs
include mechanics for tail-calls that allow reuse of stack frames.
Until such support exists, there's no much we can do in j.u.c,
or anywhere in JDK, to help. But if you are operating at
the compiler/tool level (as you are for Ruby), you can still
perform code transformations that get most of these effects.

-Doug



More information about the Concurrency-interest mailing list