-
-
Save emretanriverdi/62e78651ff15a4aecc91e36e75555a12 to your computer and use it in GitHub Desktop.
select-channel.go
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
func main() { | |
c1 := make(chan string) | |
c2 := make(chan string) | |
go invalidateCrucial(c1) | |
go invalidateNotSoCruical(c2) | |
for { | |
fmt.Println(<-c1) | |
fmt.Println(<-c2) | |
} | |
} | |
func invalidateCrucial(c chan string) { | |
for { | |
time.Sleep(time.Second * 5) | |
c <- "Every 5sec" | |
} | |
} | |
func invalidateNotSoCruical(c chan string) { | |
for { | |
time.Sleep(time.Second * 30) | |
c <- "Every 30sec" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment