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