Multi threading queue

Hello everyone!

I’m trying to create a system that calculates a lot of data in the background (basically iterating through huge arrays and do some stuff), so I can’t do that on the game thread. My idea was to create a new thread. Now the problem is that there are many running threads at the same time, because I have around 200 actors which needs this data to be calculated for each of them. My question is: Is there any way to create something like a queue of threads? I mean, there will be only one or two threads running at a time and when those finishes a new thread is started.

If I understand this correctly you are starting new threads when a job is completed. Why not have the same threads running and queue up new tasks. Starting a thread for new job is generally a bad idea as there is a overhead for thread creation. You can also look into the AsyncTask system that is available in Unreal (A new, community-hosted Unreal Engine Wiki - Announcements - Epic Developer Community Forums)