Skip to content

Instantly share code, notes, and snippets.

@sugilog
Last active August 29, 2015 14:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sugilog/d23213c02605320c8230 to your computer and use it in GitHub Desktop.
Save sugilog/d23213c02605320c8230 to your computer and use it in GitHub Desktop.
Goroutines:ベーシック
package main
import (
"fmt"
"time"
)
func say( s string ) {
for i := 0; i < 5; i++ {
fmt.Println( i, s );
time.Sleep(100 * time.Millisecond)
}
}
func main() {
go say( "first" )
say( "second" )
}
package main
import (
"fmt"
"time"
)
func say( s string ) {
for i := 0; i < 5; i++ {
fmt.Println( i, s );
time.Sleep(100 * time.Millisecond)
}
}
func main() {
go say( "first" )
}
package main
import (
"fmt"
"time"
)
func say( s string ) {
for i := 0; i < 5; i++ {
fmt.Println( i, s );
time.Sleep(100 * time.Millisecond)
}
}
func main() {
go say( "first" )
time.Sleep(1 * time.Millisecond)
say( "second" )
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment