Created
April 25, 2016 15:49
-
-
Save volker48/f75e9a1374f1cc034ac3ce9fc63e95b6 to your computer and use it in GitHub Desktop.
Simple goroutine with bug
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"log" | |
"time" | |
) | |
func main() { | |
// anonymous function | |
go func() { | |
time.Sleep(time.Second * 2) | |
// you won't see this unless your computer is very slow | |
log.Println("*********************Work complete after 2 seconds**************") | |
}() | |
for i := 0; i < 10000; i++ { | |
//doing stuff | |
log.Println(i * 4) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment