I have a python class let's call it AClass and another one MyThread which extends Thread. And in that AClass I make 2 objects of the class MyThread and I also have a semaphore which I give it as a parameter to the constructor of the MyThread class. My question is if I modify the semaphore in one MyThread object will the other MyThread object see the difference? Ex:
class AClasss:
def function:
semafor = threading.Semaphore(value=maxconnections)
thread1 = Mythread(semafor)
thread2 = Mythread(semafor)
thread1.start()
thread1.join()
thread2.start()
thread2.join()
class MyThread(Thread):
def __init__(self,semaphore):
self.semaphore = semaphore
def run():
semaphore.acquire()
"Do something here"
semaphore.release()
So does thread1 see the changes to the semaphore that thread2 does and vice versa?