Skip to content

Instantly share code, notes, and snippets.

@nikita8
Created November 13, 2018 05:23
Show Gist options
  • Save nikita8/37e28e454a16721dd52310c7d9185cf9 to your computer and use it in GitHub Desktop.
Save nikita8/37e28e454a16721dd52310c7d9185cf9 to your computer and use it in GitHub Desktop.
go Routine
package main
import(
"fmt"
"time"
)
func f(from string) {
for i := 0; i < 3; i++ {
time.Sleep(1 * time.Millisecond)
fmt.Println(from, ":", i)
}
}
func main() {
// executing the function in another goroutine concurrently with the main.
go f("goroutine")
// calling synchronously
// processing in current main thread
f("main")
fmt.Println("done")
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment