In most cases, it is safer and simpler to use queues. Simply put, a queue is a compound memory structure that is thread-safe. Queues effectively channel access to a resource to multiple threads in a sequential order, and are a recommended design pattern that uses threads for most of the scenarios that require concurrency.
The Queue module provides a way to implement different kinds of queuing, such as FIFO (default implementation), LIFO queues, and priority queues, and this module comes with a built-in implementation of all the locking semantics required for running multithreaded programs.
Here's a quick roundup of the basic usage of the Queue module:
my_queue = Queue() #create empty queuemy_queue.put(data)# put items into queue ...