Skip to content

Commit 6b4accc

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

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.__lock = [threading.Lock() for _ in xrange(5)]
9+
self._l = [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.__lock[first]:
30-
with self.__lock[second]:
29+
with self._l[first]:
30+
with self._l[second]:
3131
pickLeftFork()
3232
pickRightFork()
3333
eat()

0 commit comments

Comments
 (0)