Barrier in Python2.7 implementieren
Ich habe diesen Code mit Barriers in Python3 implementiert. Ich möchte die gleiche Funktionalität in Python2.7 erhalten, weiß aber nicht, welches Synchronisationsprimitiv als Barrieren in Python2.7 nicht vorhanden ist.
import threading
import time
from threading import Thread,Barrier
b = Barrier(2, timeout=50)
def func1():
time.sleep(3)
b.wait()
print('Working from func1')
return
def func2():
time.sleep(5)
b.wait()
print('Working from func2')
return
if __name__ == '__main__':
Thread(target = func1).start()
Thread(target = func2).start()