r/cscareerquestions • • 3d ago

Experienced Exp. C++ Dev - Getting started with multithreading ?

I have more than 15+ yrs of experience with C++ working on large applications, however it's limited to desktop applications only, no backend, networking etc. Only very few months working with multithreading or even databases. Though I do keep myself updated with latest releases and I keep using the modern C++ feature to update the legacy code as an example.

Now to stay relevant in market I feel the need to upskill and one area I identified is multithreading and concurrency, because Gemini says for me*: "Because your exp. is concentrated in heavy desktop applications with no backend, networking, or database exposure, you are effectively locked out of Principal roles at product startups, fintech, and cloud companies."*

Could you please suggest where to begin, and resources suitable for soneone with intermediate level C++ proficiency.

Is C++ Concurrency in Action good or outdated?

Edit to clarify: I have used it, like putting mutexes and locks where appropriate, making certain classes and code thread safe. But it was mostly fixing issues after someone introduced threading in architecture. I mean nothing building from ground up and even fixing issues too was long back.

Thanks in advance for your suggestions!

9 Upvotes

13 comments sorted by

11

u/markosdaget 3d ago

concurrency in action 2nd edition still holds up for the core stuff - threads, atomics, the memory model. after that build something small like a thread pool or a lock free queue and profile it, and look at C++20 jthread and coroutines since thats where newer codebases are going

2

u/Select_Transition287 3d ago

Thanks for the response. these are clearly actionable steps. Btw, I updated the post to include context

1

u/markosdaget 3d ago

no problem - start small with something like a producer consumer queue and get that solid before going anywhere near lock free stuff tho

6

u/Rafadazdoit 3d ago edited 3d ago

I do find it a bit strange that you have 15+ years and have never multi-threaded.

It’s just a library you use and class you run, it’s just like running multiple programs at once, you set up a thread to do x y or z method, and there’s a multitude of ways to tie the data back in, but I usually thread all of my systems separately from one another

Like I’ll put an entire sensor on a thread

Databases are fun tho, if you ever get a chance, buy a raspberry pi and spin up a MariaDB database and play around with it, transfer on your personal network and all that.

My biggest tip for multi-threading though, just watch out for data races if you’re using each thread to process through the same thing, order doesn’t always matter, but if it does there’s a number of ways to force threads to execute in order. If it doesn’t through, you can always just spin up a new thread every time the challenge appears

1

u/Select_Transition287 3d ago

I have used it, like putting muteness and locks where appropriate, making certain classes and code thread safe. But it was mostly fixing issues after someone modified architecture. I mean nothing building from ground up and even fixing issues too was long back.

3

u/Ok-Library1020 3d ago

Once the book basics click, a small asio TCP server where a thread pool handles requests that hit a SQLite or Postgres db is a great next project. You get concurrency, IO and storage in one go, and it maps well to the backend and fintech roles you're after.

2

u/Select_Transition287 3d ago

This is such a cool idea to learn. Thanks!

1

u/Rafadazdoit 3d ago

Ooooo neat one

2

u/tymsink 3d ago

What made multithreading clear to me was debugging deadlocks and concurrency issues either on live systems or memory dumps (process and kernel). Seeing how the threads work within the system and all the ways things go wrong has helped me design, write and review thread-safe code. If you can get your hands on some hangs that you can review in a debugger I highly recommend it.

1

u/ObstinateHarlequin Embedded Software 3d ago

Scott Meyers' Effective Modern C++ is a great book and has a chapter dedicated to multithreading. I highly recommend it for any C++ dev looking to improve.

1

u/happy_csgo Freshman 20h ago

?? why are you reading books on coding

just ask gemini to teach you. actually scratch that, ask gemini to just write examples for you to review

1

u/[deleted] 3d ago

[removed] — view removed comment

1

u/AutoModerator 3d ago

Sorry, you do not meet the minimum sitewide comment karma requirement of 10 to post a comment. This is comment karma exclusively, not post or overall karma nor karma on this subreddit alone. Please try again after you have acquired more karma. Please look at the rules page for more information.

I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.