Before you do anything read the first paragraph here
First and foremost, running hundreds of threads isn't going to boost performance. It is going to instantly ruin your game.
Because afaik in Windows and Linux the schedulers wakes up every millisecond (possibly more like 3) to check if another process needs to run. So if you have 50 tanks and 100 soldiers that means that you can hope for 7 frames per second. Sounds great to you?
based on this link
Each tool has advantages and disadvantages. If you don't need the advantages, you still suffer from the disadvantages if you misuse it needlessly.
tl;dr Basically, threading is "Would you do that for me? But don't stop doing this while you do that other thing. It is also sometimes, "Would you do that big task faster if I break down into smaller separable chunks?"
Multithreading is advantageous for:
- Software performance optimization for multi-core systems hardware. I did not see a case where that was needed for indie gaming.
- Writing software that handles multiple, possibly unrelated processes at the same time, like a server handling an unknown number of clients. This use is not as popular nowadays but it's useful to understand as a design concept.
- Running another process asynchronously without halting the main program until it's completion. For instance, lets say you have a huge DB and you are loading some statistics. You wouldn't want the GUI to freeze until it's done? Another example that was mentioned here is running a long AI process and allowing the game to continue uninterrupted.
All the above works great especially when you don't need to share data between threads although if you do, there are special variations of the usual data-structures like lists and hashes for you to do so.
It is a subtle difference but the game is one process and the units are one part (entities) of that game that continuously need to communicate with the game. They don't need to be running on their own. They need to be synchronized with the game world.
If you want to mess around with "advanced techniques", you could try the Entity Component design pattern. I don't recommend it if you are new to this. Just use an array of soldiers and possibly pool and reuse dead soldiers. Then when you have a list or whatever container you choose, iterate over the soldiers each frame and go
You may want all the units to inherit from a base unit so you could iterate over them all easily without having to treat each unit type differently in the main game loop.