{
    "mode": "pydoc",
    "parameter": "_thread",
    "section": "",
    "url": "https://www.chedong.com/phpMan.php/pydoc/_thread/json",
    "generated": "2026-06-02T15:00:48Z",
    "sections": {
        "NAME": {
            "content": "thread\n",
            "subsections": []
        },
        "MODULE REFERENCE": {
            "content": "https://docs.python.org/3.10/library/thread.html\n\nThe following documentation is automatically generated from the Python\nsource files.  It may be incomplete, incorrect or include features that\nare considered implementation detail and may vary between Python\nimplementations.  When in doubt, consult the module reference at the\nlocation listed above.\n",
            "subsections": []
        },
        "DESCRIPTION": {
            "content": "This module provides primitive operations to write multi-threaded programs.\nThe 'threading' module provides a more convenient interface.\n",
            "subsections": []
        },
        "CLASSES": {
            "content": "builtins.object\nRLock\nlock\n\nLockType = class lock(builtins.object)\n|  A lock object is a synchronization primitive.  To create a lock,\n|  call threading.Lock().  Methods are:\n|\n|  acquire() -- lock the lock, possibly blocking until it can be obtained\n|  release() -- unlock of the lock\n|  locked() -- test whether the lock is currently locked\n|\n|  A lock is not owned by the thread that locked it; another thread may\n|  unlock it.  A thread attempting to lock a lock that it has already locked\n|  will block until another thread unlocks it.  Deadlocks may ensue.\n|\n|  Methods defined here:\n|\n|  enter(...)\n|      acquire(blocking=True, timeout=-1) -> bool\n|      (acquirelock() is an obsolete synonym)\n|\n|      Lock the lock.  Without argument, this blocks if the lock is already\n|      locked (even by the same thread), waiting for another thread to release\n|      the lock, and return True once the lock is acquired.\n|      With an argument, this will only block if the argument is true,\n|      and the return value reflects whether the lock is acquired.\n|      The blocking operation is interruptible.\n|\n|  exit(...)\n|      release()\n|      (releaselock() is an obsolete synonym)\n|\n|      Release the lock, allowing another thread that is blocked waiting for\n|      the lock to acquire the lock.  The lock must be in the locked state,\n|      but it needn't be locked by the same thread that unlocks it.\n|\n|  repr(self, /)\n|      Return repr(self).\n|\n|  acquire(...)\n|      acquire(blocking=True, timeout=-1) -> bool\n|      (acquirelock() is an obsolete synonym)\n|\n|      Lock the lock.  Without argument, this blocks if the lock is already\n|      locked (even by the same thread), waiting for another thread to release\n|      the lock, and return True once the lock is acquired.\n|      With an argument, this will only block if the argument is true,\n|      and the return value reflects whether the lock is acquired.\n|      The blocking operation is interruptible.\n|\n|  acquirelock(...)\n|      acquire(blocking=True, timeout=-1) -> bool\n|      (acquirelock() is an obsolete synonym)\n|\n|      Lock the lock.  Without argument, this blocks if the lock is already\n|      locked (even by the same thread), waiting for another thread to release\n|      the lock, and return True once the lock is acquired.\n|      With an argument, this will only block if the argument is true,\n|      and the return value reflects whether the lock is acquired.\n|      The blocking operation is interruptible.\n|\n|  locked(...)\n|      locked() -> bool\n|      (lockedlock() is an obsolete synonym)\n|\n|      Return whether the lock is in the locked state.\n|\n|  lockedlock(...)\n|      locked() -> bool\n|      (lockedlock() is an obsolete synonym)\n|\n|      Return whether the lock is in the locked state.\n|\n|  release(...)\n|      release()\n|      (releaselock() is an obsolete synonym)\n|\n|      Release the lock, allowing another thread that is blocked waiting for\n|      the lock to acquire the lock.  The lock must be in the locked state,\n|      but it needn't be locked by the same thread that unlocks it.\n|\n|  releaselock(...)\n|      release()\n|      (releaselock() is an obsolete synonym)\n|\n|      Release the lock, allowing another thread that is blocked waiting for\n|      the lock to acquire the lock.  The lock must be in the locked state,\n|      but it needn't be locked by the same thread that unlocks it.\n",
            "subsections": [
                {
                    "name": "class RLock",
                    "content": "|  Methods defined here:\n|\n|  enter(...)\n|      acquire(blocking=True) -> bool\n|\n|      Lock the lock.  `blocking` indicates whether we should wait\n|      for the lock to be available or not.  If `blocking` is False\n|      and another thread holds the lock, the method will return False\n|      immediately.  If `blocking` is True and another thread holds\n|      the lock, the method will wait for the lock to be released,\n|      take it and then return True.\n|      (note: the blocking operation is interruptible.)\n|\n|      In all other cases, the method will return True immediately.\n|      Precisely, if the current thread already holds the lock, its\n|      internal counter is simply incremented. If nobody holds the lock,\n|      the lock is taken and its internal counter initialized to 1.\n|\n|  exit(...)\n|      release()\n|\n|      Release the lock, allowing another thread that is blocked waiting for\n|      the lock to acquire the lock.  The lock must be in the locked state,\n|      and must be locked by the same thread that unlocks it; otherwise a\n|      `RuntimeError` is raised.\n|\n|      Do note that if the lock was acquire()d several times in a row by the\n|      current thread, release() needs to be called as many times for the lock\n|      to be available for other threads.\n|\n|  repr(self, /)\n|      Return repr(self).\n|\n|  acquire(...)\n|      acquire(blocking=True) -> bool\n|\n|      Lock the lock.  `blocking` indicates whether we should wait\n|      for the lock to be available or not.  If `blocking` is False\n|      and another thread holds the lock, the method will return False\n|      immediately.  If `blocking` is True and another thread holds\n|      the lock, the method will wait for the lock to be released,\n|      take it and then return True.\n|      (note: the blocking operation is interruptible.)\n|\n|      In all other cases, the method will return True immediately.\n|      Precisely, if the current thread already holds the lock, its\n|      internal counter is simply incremented. If nobody holds the lock,\n|      the lock is taken and its internal counter initialized to 1.\n|\n|  release(...)\n|      release()\n|\n|      Release the lock, allowing another thread that is blocked waiting for\n|      the lock to acquire the lock.  The lock must be in the locked state,\n|      and must be locked by the same thread that unlocks it; otherwise a\n|      `RuntimeError` is raised.\n|\n|      Do note that if the lock was acquire()d several times in a row by the\n|      current thread, release() needs to be called as many times for the lock\n|      to be available for other threads.\n|\n|  ----------------------------------------------------------------------\n|  Static methods defined here:\n|\n|  new(*args, kwargs) from builtins.type\n|      Create and return a new object.  See help(type) for accurate signature.\n"
                }
            ]
        },
        "FUNCTIONS": {
            "content": "",
            "subsections": [
                {
                    "name": "allocate",
                    "content": "allocatelock() -> lock object\n(allocate() is an obsolete synonym)\n\nCreate a new lock object. See help(type(threading.Lock())) for\ninformation about locks.\n"
                },
                {
                    "name": "allocate_lock",
                    "content": "allocatelock() -> lock object\n(allocate() is an obsolete synonym)\n\nCreate a new lock object. See help(type(threading.Lock())) for\ninformation about locks.\n"
                },
                {
                    "name": "exit",
                    "content": "exit()\n(exitthread() is an obsolete synonym)\n\nThis is synonymous to ``raise SystemExit''.  It will cause the current\nthread to exit silently unless the exception is caught.\n"
                },
                {
                    "name": "exit_thread",
                    "content": "exit()\n(exitthread() is an obsolete synonym)\n\nThis is synonymous to ``raise SystemExit''.  It will cause the current\nthread to exit silently unless the exception is caught.\n"
                },
                {
                    "name": "get_ident",
                    "content": "getident() -> integer\n\nReturn a non-zero integer that uniquely identifies the current thread\namongst other threads that exist simultaneously.\nThis may be used to identify per-thread resources.\nEven though on some platforms threads identities may appear to be\nallocated consecutive numbers starting at 1, this behavior should not\nbe relied upon, and the number should be seen purely as a magic cookie.\nA thread's identity may be reused for another thread after it exits.\n"
                },
                {
                    "name": "get_native_id",
                    "content": "getnativeid() -> integer\n\nReturn a non-negative integer identifying the thread as reported\nby the OS (kernel). This may be used to uniquely identify a\nparticular thread within a system.\n"
                },
                {
                    "name": "interrupt_main",
                    "content": "interruptmain(signum=signal.SIGINT, /)\n\nSimulate the arrival of the given signal in the main thread,\nwhere the corresponding signal handler will be executed.\nIf *signum* is omitted, SIGINT is assumed.\nA subthread can use this function to interrupt the main thread.\n\nNote: the default signal handler for SIGINT raises ``KeyboardInterrupt``.\n"
                },
                {
                    "name": "stack_size",
                    "content": "stacksize([size]) -> size\n\nReturn the thread stack size used when creating new threads.  The\noptional size argument specifies the stack size (in bytes) to be used\nfor subsequently created threads, and must be 0 (use platform or\nconfigured default) or a positive integer value of at least 32,768 (32k).\nIf changing the thread stack size is unsupported, a ThreadError\nexception is raised.  If the specified size is invalid, a ValueError\nexception is raised, and the stack size is unmodified.  32k bytes\ncurrently the minimum supported stack size value to guarantee\nsufficient stack space for the interpreter itself.\n\nNote that some platforms may have particular restrictions on values for\nthe stack size, such as requiring a minimum stack size larger than 32 KiB or\nrequiring allocation in multiples of the system memory page size\n- platform documentation should be referred to for more information\n(4 KiB pages are common; using multiples of 4096 for the stack size is\nthe suggested approach in the absence of more specific information).\n"
                },
                {
                    "name": "start_new",
                    "content": "startnewthread(function, args[, kwargs])\n(startnew() is an obsolete synonym)\n\nStart a new thread and return its identifier.  The thread will call the\nfunction with positional arguments from the tuple args and keyword arguments\ntaken from the optional dictionary kwargs.  The thread exits when the\nfunction returns; the return value is ignored.  The thread will also exit\nwhen the function raises an unhandled exception; a stack trace will be\nprinted unless the exception is SystemExit.\n"
                },
                {
                    "name": "start_new_thread",
                    "content": "startnewthread(function, args[, kwargs])\n(startnew() is an obsolete synonym)\n\nStart a new thread and return its identifier.  The thread will call the\nfunction with positional arguments from the tuple args and keyword arguments\ntaken from the optional dictionary kwargs.  The thread exits when the\nfunction returns; the return value is ignored.  The thread will also exit\nwhen the function raises an unhandled exception; a stack trace will be\nprinted unless the exception is SystemExit.\n"
                }
            ]
        },
        "DATA": {
            "content": "TIMEOUTMAX = 9223372036.0\n",
            "subsections": []
        },
        "FILE": {
            "content": "(built-in)\n\n",
            "subsections": []
        }
    },
    "summary": "thread",
    "flags": [],
    "examples": [],
    "see_also": []
}