void writeLock() {
    checkForPossibilityOfWriteLock();
    assertInitialWriteState();

    writeState = WRITE_REQUESTED;
    for (int iter=0; ;iter++) {
      if (areAllReadersIdle()) {
        writeState = WRITE_ACQUIRED;
        break;
      }

      if (iter > SPIN_TO_WAIT_FOR_LOCK) {
        LockSupport.parkNanos(this, 1_000_000);  // unparked by readUnlock
      }
      else {
        Thread.yield();
      }
    }
  }
void writeLock()