Hope this helps: https://play.golang.org/p/5UnIuSE50F

package main

import "time"

func main() {
// redact
ch1 := make(chan struct{})
ch2 := make(chan struct{})
go func() {
for _, value := range []int{1, 3, 5} {
// redact
println(value)
// redact
<-ch1
ch2<-struct{}{}
}
}()

go func() {
for _, value := range []int{2, 4, 6} {
// redact
ch1<-struct{}{}
println(value)
// redact
<-ch2
}
}()

time.Sleep(time.Second)
}



On Tuesday, September 6, 2016 at 7:08:23 AM UTC+8, Ринат Галиев wrote:
>
> Hi, i need to solve the task:
> Change the program so that the numbers 1 through 6 were printed to the 
> console in order. Allowed to amend the sections of code that are marked 
> commentary «// redact».
> https://play.golang.org/p/tUMlHWHfJE
>
> it is not work: https://play.golang.org/p/hW-9J5YfC4
>
> i know, that need to use the channels 
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to