Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You canโ€™t perform that action at this time.