GO: Concurrent vs Parallel Execution

The following figures explain the difference between concurrent and parallel execution in GO.

In concurrent execution two goroutines are active, but only one is in execution at one time. We can see this in figure (a), where execution (solid blue arrows) of goroutine1 overlap with suspension (dashed blue arrows) of goroutine2 and vice-versa. Both goroutines are making progress, but only one is active at a time. This is typically the case when running on a single processor, as shown, but concurrent goroutines can also run on multiple processors.

Parallel Execution requires two or more processors. Figure (b) shows two goroutines executing in parallel on two processors. In this case both goroutines are in execution for some periods of time (solid blue arrows overlap). The goroutines need to synchronize from time to time, as per the needs of the program (green dots).

In figure (c) we show two independent goroutines running separately on two processors. They require the same amount of time and there is no synchronization during their execution. This is a trivially parallel example.