The thread Module
The only part of the thread module that your code should use directly is the lock objects that module thread supplies. Locks are simple thread-synchronization primitives. Technically, thread’s locks are non-reentrant and unowned: they do not keep track of which thread last locked them, so there is no specific owner thread for a lock. A lock is in one of two states, locked or unlocked.
To get a new lock object (in the unlocked state), call the factory function named allocate_lock without arguments. This function is supplied by both modules thread and threading. A lock object L supplies three methods.
acquire |
When |
locked |
Returns |
release |
Unlocks |
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access