solution to the readers/writer lock exercise