[concurrency-interest] open up ForkJoinPool.managedBlock to other pool implementations

Mark Falco mark.falco at gmail.com
Wed Jan 22 08:34:43 EST 2020

With the updates being made to the ForkJoinPool and the wider adoption of
ManagedBlocker across the j.u.c blocking classes I'm curious if there would
be interest/willingness to open this up for use by other thread pool
implementations.  Specifically ForkJoinPool.managedBlock currently only
supports notifying ForkJoinWorkerThreads that they will be block, but it.
would seem fairly trivial to support this more generically.  For instance
there could be a BlockingAware interface which ForkJoinWorkerThread would

interface BlockingAware {
    void managedBlock(ManagedBlocker blocker)
        throws InterruptedException;

And then ForkJoinPool.managedBlock could just be:

public static void managedBlock(ManagedBlocker blocker)
    throws InterruptedException {
    Thread t = Thread.currentThread();
    if (t instanceof BlockingAware)
        ((BlockingAware) t).managedBlock(blocker);

With ForkJoinWorkerThread's managedBlock implementation being:

void managedBlock(ManagedBlocker blocker) {
    if (pool == null) {
    else {

This would then allow other thread pool implementations to implement
BlockingAware and to be notified when their threads block on a

I suppose taking things a bit further ManagedBlocker should exist at j.u.c
with FJP.ManagedBlocker extending that, and similarly the FJP.managedBlock
static method would ideally also be exposed on class other then FJP,
perhaps as a static method on ManagedBlocker itself.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://cs.oswego.edu/pipermail/concurrency-interest/attachments/20200122/bfbb5e40/attachment.htm>

More information about the Concurrency-interest mailing list