Practicing goroutines
This commit is contained in:
parent
f140ccceba
commit
8ad40f4930
|
@ -0,0 +1,3 @@
|
|||
module goroutines
|
||||
|
||||
go 1.22.0
|
|
@ -0,0 +1,18 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"time"
|
||||
)
|
||||
|
||||
func printText(s string) {
|
||||
for i := 0; i < 10; i++ {
|
||||
time.Sleep(time.Millisecond * 50)
|
||||
fmt.Println(s)
|
||||
}
|
||||
}
|
||||
|
||||
func main() {
|
||||
go printText("FOO")
|
||||
printText("BAR")
|
||||
}
|
Loading…
Reference in New Issue