JDK-6625724 : Allow ReentrantReadWriteLock to not track per-thread read holds
  • Type: Enhancement
  • Component: core-libs
  • Sub-Component: java.util.concurrent
  • Affected Version: 7
  • Priority: P3
  • Status: Open
  • Resolution: Unresolved
  • OS: generic
  • CPU: generic
  • Submitted: 2007-11-04
  • Updated: 2010-11-17
Related Reports
Relates :  
Description
As of jdk6, per-thread read holds are tracked by ReentrantReadWriteLock.
While very useful for catching coding errors where read lock unlock actions
are not matched by a lock action in the same thread, the cost of 
maintaining such counts was surprisingly high in runtime space and/or time.
See:
6625723 Excessive ThreadLocal storage used by ReentrantReadWriteLock
for our best attempt to mitigate this cost.

For most users, the extra safety of tracking read holds is not worth the
extra overhead.  The maintainers of ReentrantReadWriteLock now regret
having added this extra overhead.  Unfortunately, we cannot withdraw support
for this, since we added the public getReadHoldCount method.

But we can add a constructor that explicitly disclaims support for tracking
read hold counts.

Comments
EVALUATION Yes. All maintainers of ReentrantReadWriteLock agree.
04-11-2007