Last active
August 29, 2015 14:14
-
-
Save sugilog/d23213c02605320c8230 to your computer and use it in GitHub Desktop.
Goroutines:ベーシック
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" ) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" ) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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