Concurrent computing: Difference between revisions
m
→Afterfunc: library change
(→Go/Select: rearrange a few lines) |
m (→Afterfunc: library change) |
||
Line 491:
for _, w := range words {
w := w
time.AfterFunc(time.Duration(rand.Int63n(1e9)), func() {
l.Println(w)
q.Done()
Line 498:
q.Wait()
}</lang>
===Select===
This solution might stretch the intent of the task a bit. It is concurrent but not parallel. Also it doesn't sleep and doesn't call the random number generator explicity. It works because the select statement is specified to make a "pseudo-random fair choice" among
|