code: function CheckPendingThreadRequests() {
      while (PendingThreadRequests.length) {
          var tq = PendingThreadRequests.shift();
          if (!SendThreadRequest(tq)) {
              // No available thread, we queue the request, again
              PendingThreadRequests.unshift(tq);
              break;
          }
      }
  }
docs: Check if there is a request waiting and execute it on an inactive thread available