[concurrency-interest] ForkJoinPool.ManagedBlocker examples

Alex Miller alex at puredanger.com
Tue Feb 22 11:37:24 EST 2011


We're trying to make use of ManagedBlocker and the documentation is a
bit light in terms of actual usage.

AFAICT, the running task must call ForkJoinPool.managedBlock() with
the blocker implementation.  At that point, it seems the pool will
repeatedly call isReleasable() until it gets true at which it calls
block()?  Here "releasable" means the *task* can be released, not the
thing doing the blocking right?  So in the ReentrantLock example in
the ManagedBlocker javadoc
(http://gee.cs.oswego.edu/dl/jsr166/dist/jsr166ydocs/jsr166y/ForkJoinPool.ManagedBlocker.html),
isReleasable() returns true when the lock has been *acquired* so that
the blocking task can be *released*.

Also, in the ReentrantLock example, I note that hasLock is not
volatile which I found surprising.  Is the example wrong or is there
really no visibility issue there?


More information about the Concurrency-interest mailing list