@Stage("Locks")
  public String debugContextsAndLocks() {
    String message = "";
    message += "Contexts locked on this segment:\n";

    for (LocksInterface cxt = rootContextLockedOnThisSegment; cxt != null; cxt = cxt.nextNode()) {
      message += cxt.debugLocksState() + "\n";
    }
    message += "Current thread contexts:\n";
    for (int i = 0, size = chaining.contextChain.size(); i < size; i++) {
      LocksInterface cxt = chaining.contextAtIndexInChain(i);
      message += cxt.debugLocksState() + "\n";
    }
    return message;
  }
 @Stage("Locks")
 boolean tryFindInitLocksOfThisSegment(int index) {
   LocksInterface c = chaining.contextAtIndexInChain(index);
   if (c.segmentHeaderInit()
       && c.segmentHeaderAddress() == segmentHeaderAddress
       && c.locksInit()) {
     LocksInterface root = c.rootContextLockedOnThisSegment();
     this.rootContextLockedOnThisSegment = root;
     root.setNestedContextsLockedOnSameSegment(true);
     this.nestedContextsLockedOnSameSegment = true;
     this.contextModCount = root.latestSameThreadSegmentModCount();
     linkToSegmentContextsChain();
     return true;
   } else {
     return false;
   }
 }
 @Override
 public String debugLocksState() {
   String s = this + ": ";
   if (!chaining.usedInit()) {
     s += "unused";
     return s;
   }
   s += "used, ";
   if (!segmentIndexInit()) {
     s += "segment uninitialized";
     return s;
   }
   s += "segment " + segmentIndex() + ", ";
   if (!locksInit()) {
     s += "locks uninitialized";
     return s;
   }
   s += "local state: " + localLockState + ", ";
   s += "read lock count: " + rootContextLockedOnThisSegment.totalReadLockCount() + ", ";
   s += "update lock count: " + rootContextLockedOnThisSegment.totalUpdateLockCount() + ", ";
   s += "write lock count: " + rootContextLockedOnThisSegment.totalWriteLockCount();
   return s;
 }