AI Basics with AK

Season 02 - Introduction to Python Programming

Arun Koundinya Parasa

Episode 18

Multi Threading & Multi Processing! ( Conceptual & Coding - In Demo)

Agenda

  • Multi Threading
  • Multi Processing

Multi Threading & Multi Processing



Multi Threading

  • Multi Threading involves executing multiple threads within a single process.
  • Threads share the same memory space, making communication between them efficient.

Multi Processing

  • Multi Processing involves running multiple processes, each with its own memory space.
  • Processes do not share memory space, which enhances stability but makes communication more complex.

Multi Threading & Multi Processing

Multi Threading & Multi Processing

Comparison Table
Aspect Multi Threading Multi Processing
Execution Model Multiple threads within a single process Multiple processes, each with its own memory
Memory Sharing Shared memory space Separate memory spaces
Overhead Lower Higher
Communication Easier (shared memory) More complex (inter-process communication)
Use Case I/O-bound tasks CPU-bound tasks
Stability Less Stable ( shared memory risks ) More Stable (isolated processes)
Performance Efficient for tasks requiring shared data Efficient for parallel processing tasks

When to Choose which ?



- Scraping 100 websites in one go!


- Computing square-root for 10000000000 numbers!

THANK YOU

:)