nextRound
TechnologiesCoding ProblemsBookmarksLearning PathsLogin
nextRound
TechnologiesCoding ProblemsBookmarksLearning PathsLogin
nextRound

AI-powered interview preparation platform. Practice with curated questions, mock interviews, and personalized learning paths to crack your dream tech interview.

Quick Links

  • Technologies
  • Mock Interviews
  • Saved Questions
  • Pricing

Company

  • About Us
  • Contact Us

Legal

  • Privacy Policy
  • Terms of Use

© 2026 nextRound. All rights reserved.

Questions
2 of 9
1How does Python's asyncio event loop achieve concurrency without using multiple threads?
2What is the difference between threading, multiprocessing, and asyncio, and when would you choose each?
3What causes a deadlock in multithreaded code, and how can it be avoided?
4Why does multiprocessing avoid the GIL problem, and what overhead does it introduce instead?
5Given the GIL, why can multithreading still improve performance for I/O-bound tasks but not CPU-bound tasks?
6What is the difference between async def and a regular function, and what does await actually do?
7How would you run CPU-bound work alongside an asyncio application without blocking the event loop?
8What is a race condition, and how would you prevent one using threading.Lock?
9What is the Global Interpreter Lock (GIL), and why does it exist in CPython?
PythonPython
Basics
Control Flow and Functions
Data Structures
Comprehensions & Functional Programming
Iterators, Generators & Decorators
Object-Oriented Programming
Exception Handling & Debugging
Concurrency & Parallelism
Performance & Optimization
Testing
Security
Modules, Packaging & Environment
Type Hinting & Modern Python
System Design & Architecture with Python
Best Practices & Design Patterns
Edge Cases & Tricky Interview Questions
02 / 09

What is the difference between threading, multiprocessing, and asyncio, and when would you choose each?

Difficulty: 8/10
Threading, Multiprocessing, Asyncio, Concurrency Models

Threads share memory, processes isolate memory, asyncio multiplexes IO in one thread

threading runs multiple threads in one process with shared memory but serialized bytecode because of the GIL. multiprocessing runs multiple interpreter processes with separate memory, giving true CPU parallelism at the cost of serialization and IPC. asyncio runs one thread with a cooperative event loop that switches between coroutines at await points, giving very high IO concurrency with low per-task overhead but requiring non-blocking code end to end. The choice follows the workload: IO-bound with many short tasks favors asyncio or threads; CPU-bound favors processes; mixed workloads often combine them, for example an asyncio service that offloads CPU work to a process pool.

  1. 1

    threading: shared state, simple mental model, good for blocking libraries without async support, limited CPU parallelism.

  2. 2

    multiprocessing: true parallel CPU work, isolated memory, cost of pickling and process startup, harder to share state.

  3. 3

    asyncio: single thread, huge IO concurrency, must avoid blocking calls, requires async-compatible libraries end to end.

  4. 4

    Trade-off: asyncio is fastest at IO fan-out but any blocking call stalls the whole loop. Threads tolerate blocking libraries better but scale worse at high concurrency.

  5. 5

    Common mistake: mixing blocking libraries into asyncio code and accidentally freezing the loop.

  6. 6

    Common mistake: using multiprocessing with large objects and paying a serialization cost larger than the parallel speedup.

  7. 7

    Version note: asyncio was stabilized in 3.4+, and asyncio.to_thread was added in 3.9 to offload blocking calls cleanly. Process pools have been in concurrent.futures since 3.2.

javascript

Scenario Questions

0-2 years experience

  1. 1You need to run 1000 HTTP requests concurrently with minimal overhead. Which model?
  2. 2You need to use a library that only has blocking functions. Which model is the easiest fit?

2-5 years experience

  1. 1You have 100 images to resize with Pillow. Which model?
  2. 2You need shared counters across workers. Which model and what are the pitfalls?

5-8 years experience

  1. 1You have an asyncio web service that occasionally runs heavy CPU code. How do you prevent stalling the loop?
  2. 2You need to process a 5 GB stream with CPU-heavy transforms and bounded memory. How do you combine processes and async IO?

8+ years experience

  1. 1Design a hybrid concurrency architecture that uses asyncio for IO fan-out and processes for CPU stages with back-pressure, cancellation, and clean shutdown.
  2. 2Compare threading, multiprocessing, and asyncio on observability, debuggability, and failure isolation, and justify a default for a new service.

Follow-up Questions

  • How does asyncio.to_thread differ from run_in_executor with a ThreadPoolExecutor?
  • When would you choose threads over asyncio for IO-bound work?
Sharethis question

Share via WhatsApp, X, Facebook, LinkedIn or copy link. Open Graph preview enabled.