Synchronization Patterns

Patterns involving coordinating shared state between goroutines.

1. Mutex

Ensures exclusive access to a resource by one goroutine at a time.

2. Semaphore

Controls the number of goroutines allowed to access a resource at once.

3. Singleflight

Deduplicates concurrent identical calls so only one executes and all callers share the result.


Table of contents


This site is open source! You can contribute or suggest changes by editing the GitHub repository.
Copyright © 2026 Viacheslav Demianov. Distributed by an MIT license.