A few questions about multithreading.
I'm coming back to C++ after 4 years, picking up where I left off, learning multithreading, because there's some stuff I wanna learn how to do in Unreal.
I think I got the basics down, but I can tell there's a lot left for me to learn.
I have a few questions to make sue I handle threads correctly:
\-Is making a vector of threads a good idea?
1- The data I'm working with is on a vector as vector as well so I don't think I have a choice, and I did test it on the side and it works, but is it a good idea/practice? If not, why?
2- I checked at the end of the program, after joining all the threads with the main one, I expected the vector to be empty, but it's not, it had the exact number of elements that I pushed_back into it.
What is even in that vector? If all those threads are gone by that point?
3- Still assuming a vector of threads is a good idea, is just using a clear() at the end sufficient? Or is there something else I need to do to de-allocate that memory?
As you can see I'm still a bit lost so if there's anything you think I need to know, or better yet, a good, comprehensive resource about multithreading that you can point me towards, I'd be very thankful.
https://redd.it/1o8l57i
@r_cpp
Post #24072
21