I have two goroutines:
- sends even numbers in the channel
- sends odd numbers in the same channel.
In the main function, I want to print those numbers. The main function should print values in the sequence:
I have used two channels to synchronize both goroutines ie even and odd. so the first goroutine will send 0, then the second will send 1, first will send 2, and so on.
Can you please help me to optimize this code: https://play.golang.org/p/dgVWW8ew2A6
I want to use only one channel for synchronization.