[Solved] Should a class be thread-safe? [closed]


As a general rule, it’s more flexible to leave it to the user. For example, consider a map-type container. Suppose the application needs to atomically move something from one map to another map. In this case, the user needs to lock both maps before the insert-erase sequence.

Having such a scenario be automatically taken care of somehow by your class would probably be inelegant, because it’s naturally something that happens across objects, and because there may be many such scenarios, each slightly different.

solved Should a class be thread-safe? [closed]