August 2019
Beginner to intermediate
798 pages
17h 2m
English
The code of pipeline.go is not perfect and contains a logical error, which in concurrent terminology is called a race condition. This can be revealed by executing the following command:
$ go run -race pipeline.go 1 10
2 2 ==================
WARNING: DATA RACE
Write at 0x00000122bae8 by goroutine 7:
main.second()
/Users/mtsouk/ch09/pipeline.go:34 +0x15c
Previous read at 0x00000122bae8 by goroutine 6:
main.first()
/Users/mtsouk/ch09/pipeline.go:21 +0xa3
Goroutine 7 (running) created at:
main.main()
/Users/mtsouk/ch09/pipeline.go:72 +0x2a1
Goroutine 6 (running) created at:
main.main()
/Users/mtsouk/ch09/pipeline.go:71 +0x275
==================
2
The sum of the random numbers is 2.
Found 1 data race(s)
exit status 66
The ...
Read now
Unlock full access