Skip to content

Instantly share code, notes, and snippets.

@rbnpercy
Created July 30, 2019 13:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rbnpercy/cbff2df86b8233ef8a20ce044df23317 to your computer and use it in GitHub Desktop.
Save rbnpercy/cbff2df86b8233ef8a20ce044df23317 to your computer and use it in GitHub Desktop.
package main
import (
"fmt"
"math/rand"
"time"
)
func main() {
for i := 0; i < 10; i++ {
go func(i int) {
sleep := time.Duration(rand.Intn(1000))
time.Sleep(sleep * time.Millisecond)
fmt.Println(i)
}(i)
}
time.Sleep(2000 * time.Millisecond)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment