Skip to content

Commit e12ec48

Browse files
authored
Update the-dining-philosophers.py
1 parent fdf4d2e commit e12ec48

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

Python/the-dining-philosophers.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
class DiningPhilosophers(object):
88
def __init__(self):
9-
self.__m = [threading.Condition() for _ in xrange(5)]
9+
self.__lock = [threading.Lock() for _ in xrange(5)]
1010

1111
# call the functions directly to execute, for example, eat()
1212
def wantsToEat(self, philosopher, pickLeftFork, pickRightFork, eat, putLeftFork, putRightFork):
@@ -26,8 +26,8 @@ def wantsToEat(self, philosopher, pickLeftFork, pickRightFork, eat, putLeftFork,
2626
else:
2727
first, second = right, left
2828

29-
with self.__m[first]:
30-
with self.__m[second]:
29+
with self.__lock[first]:
30+
with self.__lock[second]:
3131
pickLeftFork()
3232
pickRightFork()
3333
eat()

0 commit comments

Comments
 (0)