public void beginReading() {
   super.beginReading();
   buf.flip(); // don't need to synchronize -- we hold the semaphore
 }
 public void beginWriting() {
   super.beginWriting();
   buf.clear(); // don't need to synchronize -- we hold the semaphore
 }