TGViewer
C++ - Reddit C++ - Reddit @r_cpp · 228 subscribers
Post #24072 21
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
Reddit From the cpp community on Reddit Explore this post and more from the cpp community
More from @r_cpp
  1. Oct 14, 2026I tested whether a coding agent would use C++23 ranges without being told Blog post: https…
  2. Oct 14, 2026C++ futures part 1: The mental model https://devblogs.microsoft.com/oldnewthing/20261012-0…
  3. Oct 14, 2026C++ futures part 2: The mental model for std::promise, std::packaged_task https://devblogs…
  4. Oct 12, 2026[Release] slick-logger v2.2.0 — Lock-free asynchronous C++20 logging with multi-process sh…
  5. Oct 12, 2026Cheap alternative to reboot parameters (nohz, rcu, isolcpus) for stable benchmarks When no…
  6. Oct 12, 2026This C++ drama is crazy - Adobe votes no https://www.youtube.com/watch?v=DEqx_NMMH9Q https…
Threads Profile ViewerView any public Threads profile without an account.Open ThreadLook →Writing with AI? Make it sound human.Metric37 rewrites AI drafts so they read naturally. Free AI detector, 1,500 words free.Try Metric37 →