elizarov
12/20/2016, 6:27 AMgo {}
blocks, though. Remember, that every time you invoke go{}
you start a new coroutine that works concurrently with all the other ones. Unlike the threads, coroutines are lightweight, but like the threads they potentially expose you to the nasty problem of shared mutable state. Because this go{}
block is so small and innocent-looking it is quite easy to get lost and introduce hand-to-fix heisenbugs in your code. These go{}
blocks look great for a slide-ware, but I would not recommend them for any serious large-scale project. Actor-style concurrency where each actor is defined as a separate top-level class with it own scope and its own (non-shared!) state seems to be more suited and less error-prone for large-scale projects. You don't have to do with Akka-style actors that have a single message queue, though. You can define actors without a built-in queue and use go-style non-blocking channels to establish communication between your actors.