🎙 Free live masterclass · Sun, 29 Nov, 7:00 pm IST · Java Full Stack roadmap Register free →
Skills101
← Quiz: Threads, Processes and the GIL: all 10 questions

Quiz: Threads, Processes and the GIL · Question 6 of 10

Does the GIL make balance = balance + 100 safe across threads?

Does the GIL make balance = balance + 100 safe across threads?

  1. A.Yes, the GIL protects all shared variables
  2. B.No, a thread can be paused between reading and writing; use a Lock
  3. C.Yes, but only for integers
  4. D.No, because Python has no threads
Answer & explanation

Correct answer: No, a thread can be paused between reading and writing; use a Lock

The read and the write are separate steps, and a switch can happen between them.

Can you get the rest right without peeking?

Take the timed Quiz: Threads, Processes and the GIL quiz free. Pass it to earn XP and count towards your certificate.

Start the quiz →