The Queue module is primarily used to manage to process large amounts of data on multiple threads. It supports the creation of a new queue object that can take a distinct number of items.
put() methods are used to add or remove items from a queue respectively. Below is the list of operations that are used to manage Queue:
- get(): It is used to add an item to a queue.
- put(): It is used to remove an item from a queue.
- qsize(): It is used to find the number of items in a queue.
- empty(): It returns a boolean value depending upon whether the queue is empty or not.
- full(): It returns a boolean value depending upon whether the queue is full or not.
A Priority Queue is an extension of the queue with the following properties:
- An element with high priority is dequeued before an element with low priority.
- If two elements have the same priority, they are served according to their order in the queue.
Below is a code example explaining the process of creating multi-threaded priority queue:
initializing Thread-1 initializing Thread-2initializing Thread-3 Thread-2 processing AThread-3 processing B Thread-3 processing C Thread-3 processing D Thread-2 processing E Exiting Thread-2 Exiting Thread-1 Exiting Thread-3 Exit Main Thread
Note: The output may differ depending upon the device specifications and processing power.
- Priority Queue using Queue and Heapdict module in Python
- Priority Queue in Python
- Simple Multithreaded Download Manager in Python
- Stack and Queue in Python using queue Module
- Python | Priority key assignment in dictionary
- Python - Combine dictionary with priority
- Python - Extracting Priority Elements in Tuple List
- Queue in Python
- Heap queue (or heapq) in Python
- Python | Queue using Doubly Linked List
- Fixed-priority pre-emptive scheduling
- PyQt5 | Setting visible priority to push button
- Python - Read blob object in python using wand library
- Python | PRAW - Python Reddit API Wrapper
- Python | Index of Non-Zero elements in Python list
- MySQL-Connector-Python module in Python
- Python | Convert list to Python array
- twitter-text-python (ttp) module - Python
- Reading Python File-Like Objects from C | Python
- Important differences between Python 2.x and Python 3.x with examples
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.