Slide 3
Slide 3 text
スレッドを起動して Hello World の例
-module(hello).
-export([start/0, printer/0]).
start() ->
Pid = spawn(fun printer/0),
Pid ! "Hello World~n".
printer() ->
receive
msg -> io:fwrite(msg)
end.
package main
import "fmt"
func main() {
ch := make(chan string)
go printer(ch)
ch <- "Hello World"
<-ch
}
func printer(ch chan string) {
msg := <-ch
fmt.Println(msg)
close(ch)
}