r/javahelp • u/feralalien • Oct 09 '15
Having trouble using the ReentrantReadWriteLock
I seem to be having trouble getting ReentrantReadWriteLock to work. I have done it as far as I can tell, correctly, but my audit method seems to be happening during the move method resulting in inconsistent values. From my understanding this should not be happening because a read lock should wait until the write lock has released. Any insight would be very appreciated!
4
Upvotes
View all comments
Show parent comment
1
u/feralalien Oct 09 '15
If I understand you correctly, you are saying that after the writelock is unlocked it is free game for anything to happen until either audit or move runs again? In this instance that is okay because (and I know you can't see all this but) nothing writes or reads outside of move/audit.
Or are you saying that the way it is set up would prevent a lot of audits from happening and if I want to ensure that I need a more all in one approach like: