I am reading book "Foundations of Qt Development", Chapter 12, and I read that threading is platform-dependent, can someone explain, why? I know how to use threads but that what they said is not so clear to me.
The book you are reading was published in 2007. The C++ API for managing threads wasn't standardised until 2011. At the time, on different systems you had to use entirely different platform-specific libraries (pthreads, win32 threads, etc). Now, this is no longer true. Your book is out of date.
... threading is platform-dependent, can someone explain, why?
The platform dependencies are typically differences in the way that the thread scheduler works. The fact is that thread schedulers do behave differently on different platforms due to:
- differences in the thread scheduler algorithms across different operating systems and versions.
- differences in scheduler tuning parameters; e.g. the duration of a "timeslice", whether / how the scheduler considers past thread behavior when scheduling, etc
- differences in hardware platforms; e.g. numbers of cores, etc
- differences in compilers, etc leading to differences in behaviour when threads share data structures (especially if you don't follow the rules for proper synchronization)
- differences in workload, including what else is running on the system apart from (say) the Qt application.
Why are there differences? Well, it is hard to see how one could avoid differences! It is impractical / impossible to standardize platforms to the degree that thread schedulers will behave the same.
The other aspect to platform dependency is that historically there have been a number of different C / C++ APIs for threading. (To get a feeling for the scale of this, see https://en.wikipedia.org/wiki/List_of_C%2B%2B_multi-threading_libraries.)
This is less of a problem now that there is an official C++ threading library, unless you are working on an old code-base and / or using an older C++ compiler / libraries.