diff --git a/multithreading-multiprocessing.html b/multithreading-multiprocessing.html index 2f383d6..0f43c92 100644 --- a/multithreading-multiprocessing.html +++ b/multithreading-multiprocessing.html @@ -184,6 +184,50 @@

Introduction

+

Comparison Between Multithreading and Multiprocessing

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
AspectMultithreadingMultiprocessing
Memory UsageLess memory usage/Shared memory spaceMore memory usage/Separate memory space for each process
Concurrency TypeConcurrent threads within a single processParallel processes with separate memory spaces
GIL ImpactAffected by GIL (only one thread executes Python code at a time)No GIL; multiple processes can run Python code simultaneously
Best ForI/O-bound tasks (e.g., web scraping, file I/O)CPU-bound tasks (e.g., heavy computations)
SynchronizationMore complex due to shared stateLess complex but requires IPC for communication
OverheadLower overhead, but limited by GILHigher overhead due to process creation and management, but no GIL limitation
Fault IsolationA thread crash can affect the entire processA process crash is isolated to that process
+