Concurrency structures multiple computational activities so they can make progress during overlapping periods. Go treats it as a core design concern for modern multicore, networked software and provides lightweight goroutines for independent execution. section 1.1 section 7.2.1
Concurrency is not the same as parallelism: goroutines can execute independently without guaranteeing simultaneous execution on separate processor cores. Concurrency concerns structuring code; parallelism describes execution. section 7.2.1
a = taskA() b = taskB() #1
A compact task-ordering example contrasts ordinary sequential calls with work that can be launched independently. section 7.2.1
Choose a concurrency strategy by identifying the workload and its limiting resource:
- CPU-bound work, such as video encoding, is constrained by machine architecture and available processor capacity. section 7.5.2
- I/O-bound work, such as counting lines across files or making REST requests, is constrained by operating-system, server, or remote-service limits. section 7.5.2
- Excessive concurrency can overload the system; benchmark choices such as buffered-channel size on representative hardware. section 7.5.2
Cooking two tasks concurrently
Cooking sauce and rice sequentially takes about twenty minutes, while preparing both at the same time can take about ten minutes when separate burners are available. Goroutines apply the same overlap to independently launchable tasks. section 7.2.1
A practical concurrency exercise is a cache that stores, reads, and deletes key-value pairs safely under concurrent access. Testing exposes an inadequate first design before stronger synchronization and expiration policies are added. section 7.0






















