Race Condition and How to Solve it - threading.Lock | 2MinutesPy

preview_player
Показать описание
#racecondition #concurrency #threading #threads #python #pythonprogramming #2minutespy

🖐Hey, have you ever heard of "race condition"?

Race condition?? What is that? You might ask the same question, don't worry, in this video, we'll see the race condition and how to solve it.

Race condition occurs when we run concurrent or multi-threaded programs as they access shared resources simultaneously leading to unpredictable/inconsistent results.

We can solve it using the threading.Lock() that restricts multiple threads to access shared resources simultaneously.

More 2 Minutes Python Tutorial:

@2MinutesPy
Рекомендации по теме
Комментарии
Автор

I don't get it, doesn't this make the code linear again?

tinglin
Автор

I don't quite get it. If threads are not actually executed parallelly because of the GIL, why does race condition happen?

OtooKshide
Автор

Sir, Please do reply. 
We have already GIL in python which takes care of lock of thread . Dosen't it takecare of Race Condition ?

RameshKumar-ngnf
Автор

I remember reading in a book that you can parallelize work in python like that …. Python doesn’t have true multithreading capabilities isn’t that correct ?

cyberlando
join shbcf.ru