Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
|
|
@ -0,0 +1,13 @@
|
|||
names = <|1 -> "Aristotle", 2 -> "Kant", 3 -> "Spinoza", 4 -> "Marx", 5 -> "Russell"|>;
|
||||
n = Length[names];
|
||||
rp := Pause[RandomReal[4]];
|
||||
PrintTemporary[Dynamic[Array[forks, n]]];
|
||||
Clear[forks]; forks[_] := Null;
|
||||
With[{nf = n},
|
||||
ParallelDo[
|
||||
With[{i1 = i, i2 = Mod[i + 1, nf, 1]},
|
||||
Do[Print[names[i], " thinking"]; rp; Print[names[i], " hungry"];
|
||||
CriticalSection[{forks[i1], forks[i2]},
|
||||
Print[names[i], " eating"]; rp],
|
||||
{2}]],
|
||||
{i, nf}]];
|
||||
Loading…
Add table
Add a link
Reference in a new issue