I'm glad I found this video. I've been a JEE developer for over a decade so the last time I used C++ was when the only option for threads was the pthread library. With my new job as a Principal Software Engineer, I needed to get a fast refresher on C++ especially for multi-threaded applications (heavily multi-threaded - hundreds of threads and processes). This is doing the job nicely.
I would like to highlight again that knowledge you captured and your ability in sharing your "odyssey" with community has been for sure created, approached throughout many years of experience, studying, solving problems and sitting alone at the front of PC. We need all to remember that these 4 hours of current beauty means many thousands (I suppose) for Rupesh. Thank
Hello CppNuts, this channel has been what I have been looking for a long long time as a (almost) senior C++ software engineer. The videos in the channel are more than dry and monotonous regular C++ tutorials on the internet. They are most of the time great refreshers about the topics in language even if you have decades-long experience in this field. I would like to thank you again wholeheartedly for putting out this much work in such quality. Have a nice day and keep it up! Cheers.
a collection of Rupesh's Greatest Hits (threading version) is always a welcome treat! FYI, regarding lock(m1, m2, ...) (2:50:46): I checked the STL code (GNU C++ compiler 8, C++17) - there is no timed back-off nor rearranging the order of mutexs: lock stays in a loop until it grabs all the mutexs for as long as it takes to acquire them all, in the order that they were presented in the call to lock().
I have been looking for good understanding source to study threads in cpp. And indeed this video series is the one which quenched my basic learning for thread. I am confident with threads now. 😊
3:55:18 - mutex *mu* will be locked only once with *locker* ctor on entering the scope, but next loop iterations will not call *locker* ctor! Function std::condition_variable::wait() will fail postconditions ( *locker.owns_lock()==true* and *locker.mutex()* is locked by the calling thread) on next iteration and *std::terminate* will be called. There are no need to unlock the mutex because *wait()* do it for you. Remove line 20 *locker.unlock()* and you will be fine.
just to add in section of condition variable - when you wait on the mutex while giving a predicate (here lambda function), it also evaluates to check if that is true. In this case if your balance was not 0 for the very first time, the condition variable will not wait on the lock and proceed further execution.
This is the best video I have ever seen for multi threading where all the basics are explained with real life example which makes easier to understand complexity. I have watched all 4 hours of video and I would highly recommend this . Rupesh sir teaching is like professor teaching in a class like the money heist professor 😀. I have one more request . If possible please arrange gRPC client and server in C++ using asynchronous .gRPC is a google standard protocol for client server communication but there is very less material available for c++ particularly for bidirectional streaming of client and server using asynchronous mechanism . where complex multi threading is used. Thanks a lot again for multi threading session. It really helped a lot.
I don't know about this awesome channel to learn c++ ,what are the contents are provided by you sir it is too good and these lecture videos are very much valuable for me ,thanks for providing these type of contents.🙏
I'd like to add another point related to the "Producer-Consumer" problem, it's not mandatory that both producer & consumer notify each other, There is a very good chance that the Producer blocks the incoming data received is too fast or heavy over a socket or within the process, its recommended to continuously keep track on buffer size(Rather than waiting on consumer signal) at one end and notify the consumer
Thank you for a such a wonder full session. There was a interview question around threads, Since threads by default welcomes running conditions. We have to sufficiently test the code before release it to Production. However how much of guarantee ness we will provide either as part of code review OR unit testing we will make sure all running conditions are been tested. No missing conditions will happen in Production. I have googled there are couple of tools where they execute all permutation and combinations but just want to know your thoughts.
Hi, thanks for your content! It's been really helpful. With the first example when I use threads the program actually takes longer. I have a Ryzen 5000 series CPU so I definitely have more cores available as that was a common point people in forums had pointed out.
In std::lock example 4 , can you please explain why there could be deadlock. Since locking is thread dependent and not depends on lock() function, t1 can release M1 and M2 to avoid deadlock.
std::mutex::try_lock() - is that simply speaking just like a std::mutex::lock() but with difference that it doesn't become blocking call what mutex is actually acquired by another thread and then returns false ?
Not clear, why does the CPU "decide" to be less loaded if we do not create threads (just call one function after another) than if we create threads? I mean let's say CPU has some computation power P, there is a program without threads (just calling one function after another) "Program A" and "Program B", which does use threads. If CPU applies the whole power P to run "Program A", then it will be done with each function in it faster, than it will be done with each function if it has to "switch" between threads. As a result, Program A shall take the same time as Program B. Where am I wrong?:)
@@CppNuts sir is there any way to get study material which u teach Actually to be honest watching system and mobile complete day is quite hectic so i i can gat material from where i can take hard copy and study it would be helpful Thanks bhai
I'm glad I found this video. I've been a JEE developer for over a decade so the last time I used C++ was when the only option for threads was the pthread library. With my new job as a Principal Software Engineer, I needed to get a fast refresher on C++ especially for multi-threaded applications (heavily multi-threaded - hundreds of threads and processes). This is doing the job nicely.
I would like to highlight again that knowledge you captured and your ability in sharing your "odyssey" with community has been for sure created, approached throughout many years of experience, studying, solving problems and sitting alone at the front of PC. We need all to remember that these 4 hours of current beauty means many thousands (I suppose) for Rupesh. Thank
Hi Markus, Thanks for such a nice comment.
Yes it was thought many time and took so much to find examples so that it would be clear to everyone.
Nice video. For complete series of multithreading, visit my channel: th-cam.com/video/cZEO2UoEJNE/w-d-xo.html
Best course i've ever learnt. I've watched it continuous 4 hours without break. It's no boring at all. Thanks for your great.
Thanks..
You have the power that people desire and don't have. I wish I could listen for that long.
Hello CppNuts, this channel has been what I have been looking for a long long time as a (almost) senior C++ software engineer. The videos in the channel are more than dry and monotonous regular C++ tutorials on the internet. They are most of the time great refreshers about the topics in language even if you have decades-long experience in this field.
I would like to thank you again wholeheartedly for putting out this much work in such quality. Have a nice day and keep it up! Cheers.
Thank you so much.
A great comprehensive tutorial.
a collection of Rupesh's Greatest Hits (threading version) is always a welcome treat!
FYI, regarding lock(m1, m2, ...) (2:50:46): I checked the STL code (GNU C++ compiler 8, C++17) - there is no timed back-off nor rearranging the order of mutexs: lock stays in a loop until it grabs all the mutexs for as long as it takes to acquire them all, in the order that they were presented in the call to lock().
I have been looking for good understanding source to study threads in cpp. And indeed this video series is the one which quenched my basic learning for thread. I am confident with threads now. 😊
I recently discovered this channel and you're too good man, you just keep giving. What an amazing resource!
Thanks dude..
Your videos are a life saver. Thank you so much from the bottom of my heart for helping out students and interview go-ers.
Welcome
3:55:18 - mutex *mu* will be locked only once with *locker* ctor on entering the scope, but next loop iterations will not call *locker* ctor! Function std::condition_variable::wait() will fail postconditions ( *locker.owns_lock()==true* and *locker.mutex()* is locked by the calling thread) on next iteration and *std::terminate* will be called. There are no need to unlock the mutex because *wait()* do it for you. Remove line 20 *locker.unlock()* and you will be fine.
just to add in section of condition variable - when you wait on the mutex while giving a predicate (here lambda function), it also evaluates to check if that is true. In this case if your balance was not 0 for the very first time, the condition variable will not wait on the lock and proceed further execution.
Amazing explanation cpp nuts..🎉🎉
This is the best video I have ever seen for multi threading where all the basics are explained with real life example which makes easier to understand complexity. I have watched all 4 hours of video and I would highly recommend this . Rupesh sir teaching is like professor teaching in a class like the money heist professor 😀. I have one more request . If possible please arrange gRPC client and server in C++ using asynchronous .gRPC is a google standard protocol for client server communication but there is very less material available for c++ particularly for bidirectional streaming of client and server using asynchronous mechanism .
where complex multi threading is used. Thanks a lot again for multi threading session. It really helped a lot.
Thanks Pranva Udas for such a nice comment, really encourages.
I don't know about this awesome channel to learn c++ ,what are the contents are provided by you sir it is too good and these lecture videos are very much valuable for me ,thanks for providing these type of contents.🙏
I'd like to add another point related to the "Producer-Consumer" problem, it's not mandatory that both producer & consumer notify each other, There is a very good chance that the Producer blocks the incoming data received is too fast or heavy over a socket or within the process, its recommended to continuously keep track on buffer size(Rather than waiting on consumer signal) at one end and notify the consumer
Video just explain a way, there can be multiple ways.
Thank you for a such a wonder full session. There was a interview question around threads, Since threads by default welcomes running conditions. We have to sufficiently test the code before release it to Production. However how much of guarantee ness we will provide either as part of code review OR unit testing we will make sure all running conditions are been tested. No missing conditions will happen in Production. I have googled there are couple of tools where they execute all permutation and combinations but just want to know your thoughts.
Day1 : 58:56
Day2 : 2:02:13
3 hr 55 mins thread ka Pura Gyan Mila awesome content !! fun moment dogs barking at the back -> That is not my doggy 😂😄
I remember that too 😂
Amazing! Your knowledge and teaching skills are brilliant!
Thanks Darshan
Thank you for creating this long video.
Hi Rupesh, Can u please post your blog link. So that I can get code snippets..Your videos are OSM and very helpful.
Thank you Rupesh.It is so helpful.
Thanks for watching..
Excellent lecture! Thank you! However, you forgot to mention function yield()
Hi, thanks for your content! It's been really helpful. With the first example when I use threads the program actually takes longer. I have a Ryzen 5000 series CPU so I definitely have more cores available as that was a common point people in forums had pointed out.
Please check other comments I have pined important comments to resolve it.
Thanks for making this video very useful to me. Can i know where can i get the code used in these videos
You are just awesome man.. Keep going
Excellent tutorial. Would be helpful if you could also provide links to the code in the description. Thanks.
It’s there in channels About page.
Thanks very well explained.
Perhaps could be nice to cover std::atomic as well?
Sure..
In std::lock example 4 , can you please explain why there could be deadlock. Since locking is thread dependent and not depends on lock() function, t1 can release M1 and M2 to avoid deadlock.
once in a interview i was how to design thread ........................so is this whole process should i explain ? or thread design is somthing else
Thank you, sir!
Welcome dude.. keep learning!!
Hii Rupesh.
Your explanation is very understandable, If possible Could you please provide PPT.
Working on it.
Hello Rupesh .kindly upload thread debugging using gdb .
As this topic not in list.
Thanks man..
Noted..
std::mutex::try_lock() - is that simply speaking just like a std::mutex::lock() but with difference that it doesn't become blocking call what mutex is actually acquired by another thread and then returns false ?
Great vid!
thank you so much for uploading this!
Our pleasure!
Thankyou sir 😊
Welcome
God bless you
thanks for your contribution you are the best
You're welcome!
@@CppNuts i really want to contribute you in patreon but its not accepting the payment can you help me?
And thanks for your contribution to society !
You can try joining TH-cam channel also.
Thanks
Thanks a lot
I really like your channel
Thank you very much.
03:29:08 For producer-consumer, we should be fine without unlocking the locker right? as unique_lock already unlocks
at 3:11:31 was there any benefit to sending OddSum as an rvalue , as it is just an integer ?
when to use async (with defer) vs thread? if you call future.get() its also blocking...
Sir it's very useful, also can you make videos on semaphore??
Thanks..
Noted
Thank You🙏🙏
Always welcome
Not clear, why does the CPU "decide" to be less loaded if we do not create threads (just call one function after another) than if we create threads? I mean let's say CPU has some computation power P, there is a program without threads (just calling one function after another) "Program A" and "Program B", which does use threads. If CPU applies the whole power P to run "Program A", then it will be done with each function in it faster, than it will be done with each function if it has to "switch" between threads. As a result, Program A shall take the same time as Program B.
Where am I wrong?:)
How about doing videos on threading with semaphores ?
When should we use a mutex instead of semaphore and vice versa ?
Thanks for the good topic, noted.
does promise and future uses friend function internally?
Hi Bro, Thanks for this video. but y semaphore is not covered in this??
Forgot..
Hlw sir
H i have already watched your earlier playlist on threads
Is it worth to watch this also??
Thanks for watching them, actually this is combination of all of them.
With timeline if you interested you can see which you may still want to watch.
@@CppNuts sir is there any way to get study material which u teach
Actually to be honest watching system and mobile complete day is quite hectic so i i can gat material from where i can take hard copy and study it would be helpful
Thanks bhai
And also if wouldn't mind may i know ur professional r u embedded engg and application engg or else
Application Engineer.
I am planning to upload things on git hub.
Can you give a link to the repo containing all the code so that it is go through the code again?
Chech channel's description.
can you please give us the link for the blog for code, please
It’s there in channels about page.
So, this library works on linux, what about windows?
new method to generate random numbers i guess 1:08:50
Detach() mean is independent of main() thread and will tack same time of main() thread when ended or exit.
Provide link for sources
hi were can i get the cods in this tutorial
Check about me page of the channel.
2:33 How did it execute without Chrono Library ?
Line 29 we have some includes.
shared mutex missing
Is this topic Useful in CP?
No
❤️❤️❤️❤️🔥❤️🔥❤️🔥❤️🔥❤️🔥❤️❤️