Synchronization between writers and readers with two locks. Buffer is a bounded buffer.