Answer the question
In order to leave comments, you need to log in
Why does this code behave differently on multiple runs?
https://play.golang.org/p/AhFXtRGcVba
Sometimes I get this:
!! scanLogLines
SCAN: Emitter A 1
SCAN: Emitter A 2
SCAN: Emitter A 3
SCAN: Emitter A 4
SCAN: Emitter A 5
>> log SEND - [Emitter A 1 Emitter A 2 Emitter A 3 Emitter A 4 Emitter A 5]
SCAN: Emitter A 6
SCAN: Emitter A 7
<< log RCV - [Emitter A 6 Emitter A 7 Emitter A 3 Emitter A 4 Emitter A 5]
SCAN: Emitter A 8
SCAN: Emitter A 9
SCAN: Emitter A 10
>> log SEND - [Emitter A 6 Emitter A 7 Emitter A 8 Emitter A 9 Emitter A 10]
SCAN: Emitter A 11
SCAN: Emitter A 12
<< log RCV - [Emitter A 6 Emitter A 7 Emitter A 8 Emitter A 9 Emitter A 10]
SCAN: 1=========================
>> log SEND - [Emitter A 11 Emitter A 12 1=========================]
!! /scanLogLines
<< log RCV - [Emitter A 11 Emitter A 12 1=========================]
Answer the question
In order to leave comments, you need to log in
slice contains a pointer inside, which leads to races during slice parallel processing in different goroutines
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question