Why do we need locks for threads, if we have GIL?
<p>I believe it is a stupid question but I still can't find it. Actually it's better to separate it into two questions:</p>

<p>1) Am I right that we could have a lot of threads but because of GIL in one moment only one thread is executing?</p>

<p>2) If so, why do we still need locks? We use locks to avoid the case when two threads are trying to read/write some shared object, because of GIL twi threads can't be executed in one moment, can they?</p>

<p>the GIL prevents simultaneous execution of multiple threads, but not in all situations.</p>

<p>The GIL is temporarily released during I/O operations executed by threads. That means, multiple threads can run at the same time. That's one reason you still need locks.</p>

<p>I don't know where I found this reference.... in a video or something - hard to look it up, but you can investigate further yourself</p>

python multithreading