If I have multiple go-routines going and 2 or more of them decide they need to print something out, is it possible for them to interrupt each other?
For example:
package main
import (
"fmt"
)
func main() {
go print()
print()
}
func print() {
for true {
fmt.Print("ABCDEF")
}
}
Is it possible for one go-routine to start printing (AB
) and another go-routine interrupting (ABABCDEF
) and the original finishing (ABABCDEFCDEF
)?
I've tried running it myself and checking the output and it looks good, but how can I be sure?