Advanced
Go (Golang)
Q65 / 100
What is the difference between sync.Map and a regular map with a mutex?
Correct! Well done.
Incorrect.
The correct answer is B) sync.Map is optimized for high-read, low-write workloads with disjoint sets of keys per goroutine; a mutex map is simpler and faster when writes are frequent
B
Correct Answer
sync.Map is optimized for high-read, low-write workloads with disjoint sets of keys per goroutine; a mutex map is simpler and faster when writes are frequent
Explanation
sync.Map uses two maps internally: a read-optimized atomic map and a dirty write map. It excels at stable-keyed high-concurrency reads. mutex+map is often better for write-heavy workloads.
Progress
65/100