Comment by mrkeen

1 year ago

I don't know any Go so I'll try some pseudocode that hopefully maps across well enough.

  main {
    chan = makeChannel()
    sendMsg(chan, "one")
    sendMsg(chan, "two")
    print(recvMsg(chan))
    print(recvMsg(chan))
  }

  sendMsg(...) {
    async {
      // ...
    }
  }

I argue that this code is all-red when sendMsg is allowed to spawn an extra (green)thread to do its work (at the async keyword.) The order of the prints in main is unknown. If you remove the async, the code becomes all-blue and the order of the prints becomes known.