← 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?
- A.Yes, the GIL protects all shared variables
- B.No, a thread can be paused between reading and writing; use a Lock
- C.Yes, but only for integers
- 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 →