On this page
  1. threading.Thread
  2. Import
  3. Signature & Overview
  4. Methods & Attributes
  5. Usage
  6. Gotchas
  7. REPL Inspect

threading.Thread

Prev: threading.stack_size | Up: threading | Next: threading.ThreadError
Rel: threading.active_count, threading.Barrier, threading.BoundedSemaphore, threading.BrokenBarrierError
Ref: docs.python.org — threading.Thread
Tags: #public #python3 #stdlib #threading


Import

import threading
from threading import Thread

Signature & Overview

threading.Thread(group=None, target=None, name=None, args=(), kwargs=None, *, daemon=None, context=None)

A class that represents a thread of control.

Methods & Attributes

Usage

import threading

results: list[int] = []
t = threading.Thread(target=lambda x: results.append(x * 2), args=(21,), name="doubler")
t.start()
t.join(timeout=2)
assert results == [42] and not t.is_alive()

Gotchas

REPL Inspect

from threading import Thread
help(Thread)

Linked from

Related notes