A “go” statement starts the execution of a function call as an independent concurrent thread of control, or goroutine , within the same address space.
The Go runtime scheduler runs the goroutines concurrently in a pseudorandom, fair fashion.
Since you can’t predict the throw of a fair dice, you will have to try loading the dice. For example,
package main
import (
"fmt"
"runtime"
"sync"
)
var wg sync.WaitGroup
func main() {
runtime.GOMAXPROCS(1)
wg.Add(2)
go func() {
fmt.Println("Hello form one")
wg.Done()
}()
runtime.Gosched()
go func() {
fmt.Println("Hello form two")
wg.Done()
}()
wg.Wait()
}