Thread safety means allowing multiple concurrent execution paths to access and modify a shared resource without incorrect behavior or data races. The question becomes practical when a cache receives simultaneous operations. section 7.1.3
A sequential test cannot establish thread safety because its ordered operations make the result predictable. A meaningful check must simulate simultaneous calls, such as several goroutines updating a cache during overlapping requests. section 7.3
A shared cache
Consider a generic cache with Read, Upsert, and Delete operations over a map. Two concurrent Upsert calls targeting the same key create the central safety question: how can the design show that shared access will not break the cache? Testing can expose bugs, but cannot prove their absence; synchronization, including mutexes when necessary, must be considered in the design. section 7.3 section 8.7







