Someone
public text v1 · immutableclass Semaphore():
def __init__(self,startingCount):
count = startingCount
def down():
while count <= 0:
# We must wait
self.waitUntilRunning.wait()
count=count-1
def up():
count=count+1
# notify a waiting thread to wakeup
if count == 1 :
self.waitUntilRunning.notify()
class Philosopher (Thread):
s=Semaphore[N]