On Sun, Mar 17, 2019 at 8:36 PM Louki Sumirniy < louki.sumirniy.stal...@gmail.com> wrote:
> So I am incorrect that only one goroutine can access a channel at once? I don't understand, only one select or receive or send can happen at one moment per channel, so that means that if one has started others can't start. All channel operations can be safely used by multiple, concurrently executing goroutines. The black box inside the channel implementation can do whatever it likes as long as it follows the specs and memory model. But from the outside, any goroutine can safely send to, read from, close or query length of a channel at any time without any explicit synchronization whatsoever. By safely I mean "without creating a data race just by executing the channel operation". The black box takes care of that. However, the preceding _does not_ mean any combination of channel operations performed by multiple goroutines is always sane and that it will, for example, never deadlock. But that's a different story. -- -j -- 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.