This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import thread | |
import time, random | |
import threading | |
fork = list() | |
# Fixed eating time | |
eating_time = random.randint(1, 4) | |
for i in range(5): | |
fork.append({'status': False, 'owner': None}) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import thread | |
import time, random | |
import threading | |
fork = list() | |
for i in range(5): | |
fork.append(threading.Semaphore(1)) | |
def philosopher(f): | |
f = int(f) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
while True: | |
print "Love" |