Go’s concurrency model is based on “Do not communicate by sharing memory; instead, share memory by communicating”, and channels is the way of achieving this. Channels are used for inter Go Routine communication. Unlike other programming language where objects/memory is shared between two or more thread by acquiring lock, in Go channels are used to pass the objects to Go Routine thereby ensuring only one Go Routine have access to it.
One of the most talked feature of Go is its support for Concurrency and Go Routine and Channel are the two most important instrument provided by Go for concurrency. In today’s blog we will try and understand what Go Routine is and how to use it. But we before start, let us try and understand what Concurrency is? Concurrency The most common answer is doing things in parallel and in case of programming, executing the piece of code in parallel.