โ† All POC Flashcard Decks

Concurrency & Multithreading Flashcards

7 cards from real POC practice questions. Tap to flip, then mark Knew It or Still Learning โ€” missed cards come back until you master them.

Read the first 7 Concurrency & Multithreading flashcards as text
  1. What is the Global Interpreter Lock (GIL) in Python?

    Answer: A mutex that prevents multiple threads from executing Python bytecodes simultaneously

    The GIL is a mutex in CPython that allows only one thread to execute Python bytecode at a time, even on multi-core processors.

  2. Which Python module provides the Thread class for creating and managing threads?

    Answer: threading

    The `threading` module provides the Thread class along with synchronization primitives like Lock, Event, and Semaphore.

  3. What is the key difference between threading and multiprocessing in Python?

    Answer: Threading shares memory space; multiprocessing uses separate memory spaces per process

    Threads within a process share the same memory space, while multiprocessing spawns separate processes each with their own memory, bypassing the GIL for true parallelism.

  4. Which method must be called to actually start executing a thread after creating a Thread object?

    Answer: thread.start()

    thread.start() initializes the thread and calls run() internally; calling run() directly executes it in the current thread instead of a new one.

  5. What does calling thread.join() accomplish in a Python program?

    Answer: Blocks the calling thread until the joined thread finishes execution

    join() causes the calling thread (usually the main thread) to wait until the target thread completes, ensuring orderly execution.

  6. What Python keyword is used to define an asynchronous function (coroutine)?

    Answer: async

    The `async def` syntax defines a coroutine function; `await` is used inside it to suspend execution until an awaitable completes.

  7. What is a race condition in the context of multithreaded Python programs?

    Answer: A bug where program output depends on the unpredictable timing and ordering of thread execution

    A race condition occurs when multiple threads access shared data concurrently and the result depends on the non-deterministic order in which they execute.