Home

Mutex Locks

Example

""" This is a short example demoing how it works, but this example isn't realistic. Worth thinking about when using thread pools though and accessing shared resources. """ import random import csv import threading lock = threading.Lock() sum = 0 data = list(range(1000)) for element in data: with locks: sum += element

Repository

https://github.com/okeeffed/developer-notes-nextjs/content/python/mutex-locks

Sections


Related