Go言語の並行処理入門
Goゴルーチン
Goのゴルーチンはグリーンスレッドで、goキーワードで起動します。
package main
import (
"fmt"
"time"
)
func printMessage(msg string) {
for i := 0; i < 5; i++ {
time.Sleep(100 * time.Millisecond)
fmt.Println(msg)
}
}
func main() {
go printMessage("world")
printMessage("hello")
}
チャネル
...
7月16日 23:12 投稿