def METHOD_NAME(thread, wrapper):
    """ Adds the indicated core.Thread object, with the indicated Python
    wrapper, to the thread list.  Returns the new thread ID. """
    global _nextThreadId
    _threadsLock.acquire()
    try:
        threadId = _nextThreadId
        _nextThreadId += 1
        thread.setPythonIndex(threadId)
        _threads[threadId] = (thread, {}, wrapper)
        return threadId
    finally:
        _threadsLock.release()