In the class ReentrantReadWriteLock is the following curious comment:
transient ThreadLocalHoldCounter readHolds;
Sync() {
readHolds = new ThreadLocalHoldCounter();
setState(getState()); // ensures visibility of readHolds
}
what does it mean by "ensures visibility"? The reason I ask is that I have a situation where it looks as though the thread local readHolds is being reset (thread locals are implemented as WeakReferences so that shouldn't happen as long as the containing Sync object is still alive). setState/getState simply alter another instance variable and don't touch readHolds.