mirror of
https://gitflic.ru/project/openide/openide.git
synced 2025-12-16 22:51:17 +07:00
20 lines
366 B
Python
20 lines
366 B
Python
from threading import Thread, RLock
|
|
from time import sleep
|
|
lock = RLock()
|
|
|
|
|
|
def foo():
|
|
sleep(1)
|
|
while True:
|
|
lock.acquire()
|
|
x = 12
|
|
sleep(0.01)
|
|
lock.release()
|
|
print("finished foo()", x)
|
|
|
|
|
|
threads = [Thread(target=foo, name="Thread1"),
|
|
Thread(target=foo, name="Thread2")]
|
|
|
|
for thread in threads:
|
|
thread.start() |