開発環境
- macOS Mojave - Apple (OS)
- Emacs (Text Editor)
- Windows 10 Pro (OS)
- Visual Studio Code (Text Editor)
- Go (プログラミング言語)
Head First Go (Jay McGavren(著)、O'Reilly Media)のChapter 13(sharing work - Goroutines and Channels)、Code Magnets(388)の解答を求めてみる。
コード
package main
import (
"fmt"
"time"
)
func repeat(s string) {
for i := 0; i < 25; i++ {
fmt.Print(s)
}
}
func main() {
go repeat("y")
go repeat("x")
time.Sleep(time.Second)
fmt.Println()
}
入出力結果(Bash、cmd.exe(コマンドプロンプト)、Terminal)
$ go run sample1.go yyyyyyyyyyyyyyyyyyyyyyyyxxxxyxxxxxxxxxxxxxxxxxxxxx $
0 コメント:
コメントを投稿