Changed Task Philosopher
This commit is contained in:
parent
b5fc96ef94
commit
7dfa09a53e
|
@ -46,7 +46,7 @@ class ForkManager {
|
||||||
Fork rightFork = rightFork(philosopherId);
|
Fork rightFork = rightFork(philosopherId);
|
||||||
// acquire forks sequentially
|
// acquire forks sequentially
|
||||||
while(!(leftFork.getState() == FREE && rightFork.getState() == FREE)){
|
while(!(leftFork.getState() == FREE && rightFork.getState() == FREE)){
|
||||||
forkDelay();
|
forkDelay(); //wait if not both forks are available
|
||||||
}
|
}
|
||||||
leftFork.acquire(philosopherId);
|
leftFork.acquire(philosopherId);
|
||||||
forkDelay();
|
forkDelay();
|
||||||
|
|
Loading…
Reference in New Issue