Rendezvous: Difference between revisions
→{{header|Go}}: updated to use new WaitGroup feature. also improved exception message.
(Go solution) |
(→{{header|Go}}: updated to use new WaitGroup feature. also improved exception message.) |
||
Line 230:
"fmt"
"strings"
"sync"
)
Line 249 ⟶ 250:
reservePrinter := startMonitor(newPrinter(5), nil)
mainPrinter := startMonitor(newPrinter(5), reservePrinter)
var busy sync.WaitGroup
go writer(mainPrinter,
busy.Wait()
▲ go writer(mainPrinter, mgText, mgDone)
}
Line 303 ⟶ 302:
}
func writer(printer *rSync, id, text string,
for _, line := range strings.Split(text, "\n", -1) {
if e := printer.rendezvous(line); e != nil {
fmt.Println("****
break
}
}
}</lang>
Output:
<pre>
Old Mother Goose,
Humpty Dumpty sat on a wall.
Humpty Dumpty had a great fall.
Line 323:
Jack's mother came in,
And caught the goose soon,
****
</pre>
=={{header|Oz}}==
|