Hi

to get a synchronization with goroutines you need to use an unbuffered channel. 
you have used a buffered channel of 1.

Sent from my iPhone

> On 24. Jan 2019, at 22:11, diego patricio <dipas...@gmail.com> wrote:
> 
> Hi all, i'am just learning Go and goroutines, I have three goroutines (main, 
> producer, consumer) and I dont know how synchronize producer and consumer for 
> print one value at time, the output that I want is
> 
> Producer 0
> Consumer 0
> Producer 1
> Consumer 1
> ...... 
> but the output of my program it's diferent.
> 
> the program:
> 
> <image.png>
> 
> The output:
> 
> <image.png>
> 
> Sorry about my english
> 
> Regards
> -- 
> 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.

-- 
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