Welcome to my multithreaded programming project for the Advanced Programming course. This project demonstrates how Python's threading module can be used to parallelize common algorithms and tasks, improving performance through concurrency.
| File Name | Description |
|---|---|
01_multithreaded_merge_sort.py |
Multi-threaded implementation of Merge Sort |
02_multithreaded_quicksort.py |
Multi-threaded implementation of Quick Sort |
03_concurrent_file_downloader.py |
Downloads multiple files concurrently using threads |
Each script includes both single-threaded and multi-threaded implementations, along with performance comparisons.
This script parallelizes the classic merge sort algorithm using Pythonβs threading module.
- Recursively splits the array and sorts sub-arrays in separate threads.
- Merges sorted results.
- Compares execution time with the single-threaded version.
python 01_multithreaded_merge_sort.pyThis script introduces concurrency into the quicksort algorithm.
- Sub-arrays are sorted in parallel threads after partitioning.
- Thread count is managed to prevent system overload.
- Execution time of threaded vs non-threaded versions is compared.
python 02_multithreaded_quicksort.pyThis program downloads multiple files from the internet using threads.
- Accepts URLs from the user, a text file, or a built-in sample list.
- Downloads files both sequentially and concurrently using Python threads.
- Prints time taken for both approaches and calculates the speedup.
python 03_concurrent_file_downloader.py- https://speed.hetzner.de/1MB.bin
- https://speed.hetzner.de/10MB.bin
- https://file-examples.com/wp-content/uploads/2017/10/file-example_PDF_1MB.pdf
These files are publicly available and used only for testing download speed.
Each script includes time tracking to showcase the benefit of multithreading for both I/O-bound and divide-and-conquer problems.
- Merge Sort: ~2β3x faster with threads on large arrays.
- Quicksort: Performance gains vary based on thread limits and input size.
- File Downloader: Threads dramatically reduce total download time.
- Python 3.x
- No external libraries required (uses only built-in modules like
threading,time,urllib, etc.)
Abhay Singh
BTech β Computing & Data Science
Sai University, Chennai