Goroutines
Example
package main
import (
"fmt"
"time"
)
func print(s string) {
for i := 0; i < 5; i++ {
time.Sleep(100 * time.Millisecond)
fmt.Println(s)
}
}
func main() {
go print("Oliver")
print("Hello!")
}Last updated
package main
import (
"fmt"
"time"
)
func print(s string) {
for i := 0; i < 5; i++ {
time.Sleep(100 * time.Millisecond)
fmt.Println(s)
}
}
func main() {
go print("Oliver")
print("Hello!")
}Last updated
Hello!
Oliver
Oliver
Hello!
Hello!
Oliver
Oliver
Hello!
Hello!