Go Using Channel
go\n\n// count of Philosophers\nconst P = 5\n\n// times of eat\nconst N = 1\n\ntype DiningPhilosophers struct {\n\tforks [P]chan struct{}\n}\n\nfunc NewDiningPh
```go\n\n// count of Philosophers\nconst P = 5\n\n// times of eat\nconst N = 1\n\ntype DiningPhilosophers struct {\n\tforks [P]chan struct{}\n}\n\nfunc NewDiningPhilosophers() *DiningPhilosophers {\n\tforks := [P]chan struct{}{}\n\tfor i := 0; i < P; i++ {\n\t\tforks[i] = make(chan struct{}, 1)\n\t\tforks[i] <- struct{}{}\n\t}\n\treturn &DiningPhilosophers{forks: forks}\n}\n\nfunc (x *DiningPhilosophers) WantsToEat(\n\tphilosopher int,\n\tpickLeftFork func(),\n\tpickRightFork func(),\n\teat func(),\n\tputLeftFork func(),\n\tputRightFork func(),\n) {\n\tvar left, right chan struct{}\n\tif philosopher == 0 {\n\t\t// reverse\n\t\tleft, right = x.forks[0], x.forks[P-1]\n\t} else {\n\t\tleft, right = x.forks[philosopher-1], x.forks[philosopher]\n\t}\n\n\t<-left\n\tpickLeftFork()\n\t<-right\n\tpickRightFork()\n\teat()\n\tleft <- struct{}{}\n\tputLeftFork()\n\tright <- struct{}{}\n\tputRightFork()\n}\n\nfunc main() {\n\tresultCh := make(chan [3]int)\n\n\tresults := make([][3]int, 0)\n\tgo func() {\n\t\tfor {\n\t\t\tv, ok := <-resultCh\n\t\t\tif !ok {\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tresults = append(results, v)\n\t\t}\n\t}()\n\n\tdp := NewDiningPhilosophers()\n\n\tvar g sync.WaitGroup\n\n\tfor i := 0; i < P; i++ {\n\t\ti := i\n\t\tg.Add(1)\n\t\tgo func() {\n\t\t\tdefer g.Done()\n\t\t\tfor j := 0; j < N; j++ {\n\t\t\t\tdp.WantsToEat(i,\n\t\t\t\t\tfunc() { resultCh <- [3]int{i, 1, 1} },\n\t\t\t\t\tfunc() { resultCh <- [3]int{i, 2, 1} },\n\t\t\t\t\tfunc() { resultCh <- [3]int{i, 0, 3} },\n\t\t\t\t\tfunc() { resultCh <- [3]int{i, 1, 2} },\n\t\t\t\t\tfunc() { resultCh <- [3]int{i, 2, 2} },\n\t\t\t\t)\n\t\t\t}\n\t\t}()\n\t}\n\n\tg.Wait()\n\tclose(resultCh)\n\n\tfmt.Println(results)\n}\n\n```
['Go']