docs: private void checkForMCsOnThread(int maxNumberOfMCsAllowableInThread2) throws ResourceException {
          // Get the thread id.
          String ivThreadId = RasHelper.getThreadId();
          // Counter for matching threads.
          int numberOfMatchingThreads = 0;
          // Store matching thread ids for the MCW.
          ArrayList<com.ibm.ejs.j2c.MCWrapper> matchingMCWsOnThisThread = new ArrayList<com.ibm.ejs.j2c.MCWrapper>();
  
          //synchronized (mcToMCWMapLock) {
          mcToMCWMapWrite.lock();
          try {
              // Search the mc to mcw map for managed connection already being used on this thread.
              Collection<MCWrapper> s = mcToMCWMap.values();
              Iterator<MCWrapper> i = s.iterator();
              while (i.hasNext()) {
                  com.ibm.ejs.j2c.MCWrapper mcw = (com.ibm.ejs.j2c.MCWrapper) i.next();
                  if (ivThreadId.equals(mcw.getThreadID())) {
                      // We have a matching thread id that already has a managed connection inuse.
                      // Store the managed connection wrapper for debug if needed.
                      matchingMCWsOnThisThread.add(mcw);
                      ++numberOfMatchingThreads;
                      // If the number of matching threads exceeds the max set by the customer, start processing the mcw and
                      // thread information
                      if (numberOfMatchingThreads >= maxNumberOfMCsAllowableInThread2) {
                          StringBuffer matchingThreadBuffer = new StringBuffer(1000);
                          for (int j = 0; j < numberOfMatchingThreads; ++j) {
                              // Process the mcw and other data for the resource exception.
                              mcw = matchingMCWsOnThisThread.get(j);
                              long startHoldTime = mcw.getHoldTimeStart();
                              long holdTime = System.currentTimeMillis() - startHoldTime;
                              Date startDateTime = new Date(startHoldTime);
                              long timeInUseInSeconds = holdTime / 1000;
                              Throwable t = mcw.getInitialRequestStackTrace();
                              if (t != null) {
                                  matchingThreadBuffer.append("  " + mcw);
                                  matchingThreadBuffer.append("     Start time inuse " + startDateTime + " Time inuse " + timeInUseInSeconds + " (seconds)" + nl);
                                  matchingThreadBuffer.append("     Last allocation time " + new Date(mcw.getLastAllocationTime()) + nl);
                                  matchingThreadBuffer.append("       getConnection stack trace information:" + nl);
                                  StackTraceElement[] ste = t.getStackTrace();
                                  for (int k = 0; k < ste.length; ++k) {
                                      if (k > 1)
                                          matchingThreadBuffer.append("          " + ste[k].toString() + nl);
                                  }
                                  matchingThreadBuffer.append(nl);
                              }
                          }
                          String debugText = "Exceeded the number of allowable managed connection on thread " +
                                             ivThreadId + ".  " + maxNumberOfMCsAllowableInThread2 +
                                             " managed connections are already being used on this thread.  " +
                                             "  Managed connection being used on this thread " + nl +
                                             matchingThreadBuffer.toString();
                          if (tc.isDebugEnabled()) {
                              Tr.debug(this, tc, debugText);
                          }
  
                          throw new ResourceException(debugText);
                      }
                  }
              }
          } finally {
              mcToMCWMapWrite.unlock();
          }
      }