Junior — Senior
What output will the program produce in example №41
livecode
Task condition
Determine what text will be output to the console after executing the following Go program:
import (
"fmt"
)
func main() {
var highest int
for counter := 1000; counter > 0; counter-- {
go func() {
if counter%2 == 0 && counter > highest {
highest = counter
}
}()
}
fmt.Println("Maximum is %d", highest)
}
Pay attention to the behavior of goroutines and variable capture in the loop.