if the intent is to "print" the producer's output before the consumer's, then this example still can't guarantee it; for example: https://play.golang.org/p/2sb67Qf5IPd
the only synchronization guarantee is the moment of exchange on the channel. On Fri, Jan 25, 2019 at 3:27 AM Wagner Riffel <wgrrif...@gmail.com> wrote: > maybe it's the way you approached the problem, here is a perhaps cleaner > way to achieve desired output, https://play.golang.org/p/3a4lxbjdQAr > > BR. > > On Thu, Jan 24, 2019 at 7:12 PM 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: image.png] >> >> The output: >> >> [image: 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. > -- 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.