PYnative

Python Programming

  • Learn Python
    • Python Tutorials
    • Python Basics
    • Python Interview Q&As
  • Exercises
  • Quizzes
  • Code Editor
Home » Python » Quizzes » Python Multithreading and Multiprocessing Quiz (30 MCQs with Answers)

Python Multithreading and Multiprocessing Quiz (30 MCQs with Answers)

Updated on: August 29, 2025 | Leave a Comment

Looking to strengthen your understanding of Python multithreading and multiprocessing? This quiz brings you 25 carefully selected multiple-choice questions (MCQs) with answers and explanations.

Each question covers essential concurrency concepts, including the Global Interpreter Lock (GIL), thread synchronization, process pools, inter-process communication (IPC), and performance trade-offs.

Whether you’re preparing for Python interviews or coding assessments, By practicing these, you’ll strengthen your grasp of concurrency, synchronization, and parallelism — and be better prepared for coding interviews.

What’s Covered?

  • Threads vs Processes: GIL; use threads for I/O, processes for CPU.
  • Lifecycle: start()/join(), daemon threads/processes, if __name__ == "__main__":.
  • Sync: Lock, RLock, Semaphore, Event, Condition, Barrier.
  • Pools & Mapping: ThreadPool vs ProcessPool; map() order vs as_completed(); chunksize.
  • Sharing & IPC: Queue/Pipe, Manager proxies, SharedMemory/Array/Value.
  • Pitfalls & Perf: Race conditions, deadlocks, signals (main thread), process/pickling overhead.

Quiz Structure and Instructions

  • 25 random questions will be selected from a pool of 40+ multithreading MCQs.
  • No time limit – solve at your own pace.
  • Each question has 4 options; choose the correct one.
  • 1 point for every correct answer.
  • Score 15 or more to pass.
  • Each answer includes an explanation for better understanding.

1. Which concurrent.futures function yields futures as they complete (any order)?

 
 
 
 

2. What will be the output of the following code

from multiprocessing import Process
count = 0

def inc():
    global count
    count += 1

p = Process(target=inc)
p.start(); p.join()
print(count)
 
 
 
 

3. What does the GIL (Global Interpreter Lock) in CPython primarily affect?

 
 
 
 

4. What does Barrier do in threading?

 
 
 
 

5. What happens if you call future.result(timeout=1) and it doesn’t finish in time?

 
 
 
 

6. What will be the output of the following code

from multiprocessing import Process
import time, os

def child():
    time.sleep(0.05)
    print("child")

p = Process(target=child)
p.daemon = True
p.start()
time.sleep(0.01)
print("parent")
 
 
 
 

7. What will be the output of the following code of Queue with worker thread

import threading, queue

q = queue.Queue()

def worker():
    while True:
        x = q.get()
        if x is None: break
        print(x * 2)
        q.task_done()

t = threading.Thread(target=worker)
t.start()
q.put(1); q.put(2)
q.put(None)
t.join(timeout=0.1)
 
 
 
 

8. Which best describes Condition in threading?

 
 
 
 

9. What is freeze_support() used for?

 
 
 
 

10. What will be the output of the following code

from multiprocessing import Process, Manager
import time

def add(lst, val, delay):
    time.sleep(delay)
    lst.append(val)

with Manager() as m:
    lst = m.list()
    p1 = Process(target=add, args=(lst, "A", 0.02))
    p2 = Process(target=add, args=(lst, "B", 0.01))
    p1.start(); p2.start()
    p1.join(); p2.join()
    print("".join(lst))
 
 
 
 

11. Which of the following is most accurate about I/O-bound tasks?

 
 
 
 

12. Which module provides a high-level thread pool in Python?

 
 
 
 

13. In multiprocessing, which statement is required on Windows/macOS to avoid infinite child spawning?

 
 
 
 

14. What will be the output of the following code

from multiprocessing import Process, Queue

def child(q):
    q.put("x")

q = Queue()
p = Process(target=child, args=(q,))
p.start(); p.join()
print(q.get())
 
 
 
 

15. Which call properly starts a thread?

 
 
 
 

16. In multiprocessing, the recommended object for passing large arrays efficiently between processes is:

 
 
 
 

17. What will be the output of the following code

import threading

def f(name):
    print(name)

t = threading.Thread(target=f, args=("T1",))
print("A")
t.start()
t.join()
print("Z")
 
 
 
 

18. How do processes typically share state safely?

 
 
 
 

19. What is a deadlock?

 
 
 
 

20. For CPU-bound tasks on CPython, which is generally better for parallelism?

 
 
 
 

21. What will be the output of the following code

import threading

lock = threading.RLock()

def critical():
    lock.acquire()
    lock.acquire()
    print("inside")
    lock.release()
    lock.release()

critical()
print("done")
 
 
 
 

22. Which is true about signal handling with threads in CPython?

 
 
 
 

23. Which method blocks until a thread finishes?

 
 
 
 

24. What does daemon=True mean for a process in multiprocessing?

 
 
 
 

25. Which is best for preventing a classic race condition on shared data among threads?

 
 
 
 

Loading ... Loading …

Loading

Filed Under: Python, Python Quizzes

Did you find this page helpful? Let others know about it. Sharing helps me continue to create free Python resources.

TweetF  sharein  shareP  Pin

About Vishal

Image

I’m Vishal Hule, the Founder of PYnative.com. As a Python developer, I enjoy assisting students, developers, and learners. Follow me on Twitter.

Related Tutorial Topics:

Python Python Quizzes

All Coding Exercises:

C Exercises
C++ Exercises
Python Exercises

Python Exercises and Quizzes

Free coding exercises and quizzes cover Python basics, data structure, data analytics, and more.

  • 15+ Topic-specific Exercises and Quizzes
  • Each Exercise contains 25+ questions
  • Each Quiz contains 25 MCQ
Exercises
Quizzes

Leave a Reply Cancel reply

your email address will NOT be published. all comments are moderated according to our comment policy.

Use <pre> tag for posting code. E.g. <pre> Your entire code </pre>

In: Python Python Quizzes
TweetF  sharein  shareP  Pin

  Python Quizzes

  • 15 Python Quizzes
  • Python Online MCQ Test
  • Basic Quiz For Beginners
  • Variables and Data Types Quiz
  • Functions Quiz
  • if else and loops Quiz
  • Numbers Quiz
  • String Quiz
  • List Quiz
  • Set Quiz
  • Dictionary Quiz
  • Tuple Quiz
  • Operators and Expression Quiz
  • Input and Output Quiz
  • Multithreading and Multiprocessing Quiz
  • File Handling Quiz
  • Random Data Generation Quiz

 Explore Python

  • Python Tutorials
  • Python Exercises
  • Python Quizzes
  • Python Interview Q&A
  • Python Programs

All Python Topics

Python Basics Python Exercises Python Quizzes Python Interview Python File Handling Python OOP Python Date and Time Python Random Python Regex Python Pandas Python Databases Python MySQL Python PostgreSQL Python SQLite Python JSON

About PYnative

PYnative.com is for Python lovers. Here, You can get Tutorials, Exercises, and Quizzes to practice and improve your Python skills.

Follow Us

To get New Python Tutorials, Exercises, and Quizzes

  • Twitter
  • Facebook
  • Sitemap

Explore Python

  • Learn Python
  • Python Basics
  • Python Databases
  • Python Exercises
  • Python Quizzes
  • Online Python Code Editor
  • Python Tricks

Coding Exercises

  • C Exercises
  • C++ Exercises
  • Python Exercises

Legal Stuff

  • About Us
  • Contact Us

We use cookies to improve your experience. While using PYnative, you agree to have read and accepted our:

  • Terms Of Use
  • Privacy Policy
  • Cookie Policy

Copyright © 2018–2025 pynative.com

Advertisement