Initialize a thread. The thread is not running.
thread.Thread(callable)
Argument | Information |
---|---|
callable |
callable to run |
Return Thread
object
Start a thread.
thread.Thread.start(thread, *args, **kwargs)
*args and **kwargs arguments are passed through
Argument | Information |
---|---|
thread |
thread to start |
Return None
Join a thread to the parent thread.
thread.Thread.join(thread)
Argument | Information |
---|---|
thread |
thread to join |
Return None
Get ID of a thread
thread.Thread.getid(thread)
Argument | Information |
---|---|
thread |
thread to join |
Return int
that contains ID
Create an unlocked mutex.
thread.Mutex()
Return Mutex
object
Aquire a mutex
- Blocking operation
thread.Mutex.acquire(mutex)
Argument | Information |
---|---|
mutex |
mutex to acquire |
Return None
Release a mutex
thread.Mutex.release(mutex)
Argument | Information |
---|---|
mutex |
mutex to release |
Return None
Create an unlocked semaphore.
thread.Semaphore(v)
Argument | Information |
---|---|
v |
starting value |
Return Mutex
object
Aquire a semaphore, decrementing its value. If the value is 0 before decrementing, the operation blocks.
thread.Semaphore.acquire(semaphore, block=True)
Argument | Information |
---|---|
semaphore |
mutex to acquire |
block |
whether to block if the value is 0 |
Return True
if block
is False
, or True
if block
is True
and the operation did not block. Otherwise, return False
.
Release a semaphore, incrementing its value
thread.Semaphore.release(semaphore)
Argument | Information |
---|---|
semaphore |
semaphore to release |
Return None