Created
March 5, 2015 12:18
-
-
Save wozozo/d428b178a4c5e4ce65cc to your computer and use it in GitHub Desktop.
This file contains hidden or 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 main() { | |
๐ := make(chan int) | |
๐จ := make(chan int) | |
๐ := make(chan int) | |
go ๅๅฎคใฎไธญใซใใ่ชๅ(๐, ๐จ, ๐) | |
๐จ <- 0 | |
time.Sleep(3 * time.Second) | |
๐ <- 0 | |
๐ <- 0 | |
} | |
func ๅๅฎคใฎไธญใซใใ่ชๅ(๐, ๐จ, ๐ chan int) { | |
for { | |
select { | |
case <-๐: | |
go ๐ฝ() | |
case <-๐จ: | |
go ๐ฉ() | |
case <-๐: | |
time.Sleep(30 * time.Second) | |
fmt.Println("๐") | |
return | |
} | |
} | |
} | |
func ๐ฝ() { | |
fmt.Println("๐ฝใ") | |
time.Sleep(10*time.Second) | |
} | |
func ๐ฉ() { | |
fmt.Println("๐ฉใ") | |
time.Sleep(3*time.Minute) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment