Logo

Programming-Idioms

History of Idiom 185 > diff from v3 to v4

Edit summary for version 4 by programming-idioms.org:
[Go] Comment: goroutine launch

Version 3

2019-09-09, 08:59:16

Version 4

2019-09-09, 09:00:38

Idiom #185 Execute function in 30 seconds

Schedule the execution of f(42) in 30 seconds.

Idiom #185 Execute function in 30 seconds

Schedule the execution of f(42) in 30 seconds.

Extra Keywords
future
Extra Keywords
future
Imports
import  "time"
Imports
import  "time"
Code
go func() {
	time.Sleep(3 * time.Second)
	f(42)
}()
Code
go func() {
	time.Sleep(3 * time.Second)
	f(42)
}()
Comments bubble
Consider adding proper synchronization where needed. Data races are forbidden!
Comments bubble
The code after the goroutine launch executes immediately.

Consider adding proper synchronization where needed. Data races are forbidden!
Doc URL
https://golang.org/pkg/time/#Sleep
Doc URL
https://golang.org/pkg/time/#Sleep
Demo URL
https://play.golang.org/p/0vUfK-ZOgZr
Demo URL
https://play.golang.org/p/0vUfK-ZOgZr