As an aside, the whole “for tasks like gaming it’s done through 1 thread only” part isn’t *entirely* true any more.
Every program is going to have a list of things to do in a specific order. A simple example might be:
– Fetch an enemy’s health and position from memory.
– Calculate how much damage the enemy takes due to an explosion based on its position.
– If the damage is less than the enemy’s health, subtract the damage from the enemy’s health and write the new health to memory.
– If the damage is greater than or equal to the enemy’s health, run some more code to handle the enemy dying.
Each step here needs to follow this order. I can’t run the “enemy dies” code until I’ve checked the two numbers. I can’t check the two numbers until I’ve calculated the damage. I can’t calculate the damage until I’ve fetched the position. Since everything has to wait for the line before it, there’s no benefit to spreading it out across multiple threads – I can’t do two lines at the same time anyway!
But what if I had to do this for, say, 100 enemies? Well, the second enemy doesn’t depend on the first, so I can do it at the same time as the first one. And I can do the third enemy at the same time as the other ones. I can do as many as I want, based on how many threads I have.
It doesn’t come for free, of course. It takes some active work to split your code up and take advantage of having multiple threads – both from the CPU and from the developers. For a lot of time, developers didn’t really bother using multiple threads. If you wanted more than 4 threads, you’d need to shell out for something really expensive. It really wasn’t worth it, so devs didn’t spend the time to make their programs multi-threaded.
Here’s the thing: the number of threads in mainstream, gamer CPUs has steadily climbed. It used to be the case that you needed to shell out some serious money for more than 4 threads. Today, however? About 80% of gamers in Steam’s hardware survey have 6 or more **physical** CPUs, with most of those having 2 threads per CPU. 16.79% have 4 physical CPUs, but many of those 4-CPU players will have 2 threads per CPU, so 8 threads (for the record, 88.55% have 2 threads per CPU). Everyone has multiple threads… So devs are using multiple threads! Modern games are *more likely* to use multiple threads, there’s a lot more games that use multiple threads. A lot of new, modern games are multi-threaded, because multi-threaded performance has grown a **lot**.
Latest Answers