Best way to multi-thread? [closed]

The correct (standard) way to do this on C and Windows is with __beginthreadex. This is usually preferred to calling CreateThread directly as CreateThread doesn’t init C runtime support for the thread. So if you create a thread using CreateThread, and call a CRT function, bad stuff can/will happen. Note that __beginthreadex calls CreateThread internally, … Read more

Is atoi multithread safe? [closed]

Is atoi multithread safe? Yes, in the linux man page of atoi() it is written: ┌────────────────────────┬───────────────┬────────────────┐ │Interface │ Attribute │ Value │ ├────────────────────────┼───────────────┼────────────────┤ │atoi(), atol(), atoll() │ Thread safety │ MT-Safe locale │ └────────────────────────┴───────────────┴────────────────┘ So it’s just using the variables you pass from your thread (locale) and is completely thread-safe (MT-Safe), as long as you … Read more

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 … Read more