📚 Learn how to solve problems and build projects with these Free E-Books ⬇️ C++ Lambdas e-book - free download here: bit.ly/freeCppE-Book Entire Object-Pascal step-by-step guide - free download here: bit.ly/FreeObjectPascalEbook 🚀📈💻🔥 My Practical Programming Course: www.codebeautyacademy.com/ Experience the power of practical learning, gain career-ready skills, and start building real applications! This is a step-by-step course designed to take you from beginner to expert in no time! 💰 Here is a coupon to save 10% on your first payment (CODEBEAUTY_YT10). Use it quickly, because it will be available for a limited time.
@sparshb9566 Жыл бұрын
How did you get spaces in the for-loop at 4:22 ? Thanks!
@muhammad.hameem Жыл бұрын
The only youtuber who teaches modern C++ in the best way possible.
@patrickmayer9218 Жыл бұрын
*The syntax for threads is thread threadName(functionName); *You are basically giving the thread a function pointer. *You need 'system("pause>nul");' rather than 'return 0;' so that your program doesn't have a runtime error. *The easiest way to have your thread update every X unit of time is to do: using namespace std::chrono_literals; using namespace std::this_thread; //and then use the sleep_for(time literal); Great video!
@chopov11 Жыл бұрын
the system("pause") actually stops the program from closing until the user gives input. To avoid the runtime error call worker1.detach() so that it detaches the function from the thread, then there will be no error when closing the program. system() function also calls commands in the terminal which i just learned. she has another video on this system.pause(). i just put this here because i came looking for answers to this stuff too lol.
@patrickmayer9218 Жыл бұрын
@@chopov11 Gotcha, thanks for the additional info :)
@sabbirahmed80123 жыл бұрын
You're doing great. I went through hundreds of tutorials but none of those taught any practical applications of C++. Building something using a language helps the learning process exciting. I appreciate your effort, ma'am and look forward to seeing a lot more exciting projects soon.
@wora11113 жыл бұрын
I am an old programmer that did this kind of thing in 8bit assembler (6800/6809). In order to debug C++ code of younger people I switched to an assembler view. Having said that I have to admit you did a very good explanation, simplifying while explaining all relevant details that I did think of. Good work!
@ian_snyder Жыл бұрын
This is the clearest explanation of multithreading I've found, thank you so much!!
@CodeBeauty8 ай бұрын
You're very welcome!
@BigG998217 күн бұрын
real shit when i hear this from her its feels so easy to understand very good video and i guess the other ones are good too
@reggiedaniels69203 жыл бұрын
Hello Saldina. it is great that you are taking the time to bring up these problems, and then explain them to us. Because above all else I want to become a great programmer just like you. So please continue doing what you are doing. I..., We need that knowledge. While you are teaching us these things you are reinforcing what you already know. Thus you gain two benefits: the joy of helping us to become great programmers, and certification that what you think that you know is actually what you know for sure. Thank you, Reggie
@vladleustean1638 Жыл бұрын
Amazing video! I just landed my first C++ software developer job and I am trying to fill the gaps that I had during the interview. You explained it exceptionally. Thank you!
@hamzarashid6390 Жыл бұрын
Hey, is it possible to get in touch with you and discuss how you got the job? I would really appreciate it, thanks.
@abelashenafi6291 Жыл бұрын
I actually came to your channel to see how to use multithreading using C++ in Visual Studio IDE. However, the way you described multithreading using the '+' and '-' characters was really "Thinking outside the box". I really liked your perspective. I'll also use your method to teach other people about multithreading as it would really help them visualize multithreading more. Thank you!
@denisceke40102 жыл бұрын
Dovoljno je samo reći: ODLIČNO! Jako dobro i kristalno jasno objašnjenje. Definitivno se vežem za ovaj kanal. Pozdrav iz Tuzle.
@papiermuecke76263 жыл бұрын
21:20 Chorono Literals 🤣😆 Thank you saldina for that great video! I just learn so much of your videos, more than i could learn in the entire internet. Keep going!!!
@CarlosSamuelGlezJB Жыл бұрын
Love your channel! And also, when I saw you have this multithreading video... I got excited!
@kaganbaltacioglu2 жыл бұрын
Hi Saldina, around 23:52, when I tested it, it worked fine without #include and #include.
@bearwolffish2 жыл бұрын
You are probably including the entire std namespace
@technicalpublishing81882 жыл бұрын
Awesome and mindblowing!! I have never seen such an understandable and clear explanation about multithreading. One senses that you simply know exactly what you are talking about. This is my channel from now on when it comes to C++ and programming in general. Thanks a lot for this brilliant channel!!!
@silque11502 жыл бұрын
Your videos are getting me through my classes. You deserve more than a few coffees. Thank you!
@dundyd36123 жыл бұрын
wow, i was very confused in class when my teacher was explaining this, and now its cristal clear 👏👏👏 brava ❤❤❤
@Kazner0h Жыл бұрын
The practical example here was super useful. I definitely find it useful when you explain the problem with certain implementations or techniques, as well. Thank you so much!
@russellvn2 жыл бұрын
Such a great video i ever seen about multi-thread. I love this. Thank you very much, Saldina
@Barzi20012 ай бұрын
Your way of exposing is killer. You really explain things such that people can really understand. As someone said, you are the princess of computers. Subscribed!
@EngineeringChampion Жыл бұрын
You are a great teacher! I've watched almost all of your videos! More Please and keep it up!
@chronologie28953 жыл бұрын
if show you error "terminate called without an active exception", just join the threads. example: std::thread worker1(function1, 'o'); std::thread worker2(function2); worker1.join(); worker2.join();
Thanks for posting the solution to "terminate called without an active exception" solution, I ran into this as well with Visual Studio 2019 Community Edition on Windows 10. The ...join() synchronization worked for me too. Thanks again!
@gonzothegreat13176 ай бұрын
I too got an error message with the code as it is at 12:08 (and before that). Abort called and exited with error code 3. The join() function seemed to have fixed it.
@uccoskun11 ай бұрын
It is great to hear some possible real life problems. It helps people to write better program with deeper insight.
@CodeBeauty8 ай бұрын
👋👋😃
@齐峰-l8x2 жыл бұрын
After finish reading cpp primer plus, found this video, really helpful, and this is one of the few videos that I can follow without turning on subtitles. Your voice is really clear and examples are easy to understand. I think you are able to write chapter 18 of cpp primer plus, truly 👍
@asdomain45032 жыл бұрын
Hey, is cpp primer a good book for a beginner??
@齐峰-l8x2 жыл бұрын
@@asdomain4503 HELLO! It depends on how you define beginner. If you have absolutely no programming experience, or have no computer related knowledge, I do not recommend you to read this book. This book is more suitable for readers who can write simple programs like "hello world" and are eager to discover what's behind them.
@asdomain45032 жыл бұрын
@@齐峰-l8x No, I am not an absolute beginner. I have programming and development experience but my C++ knowledge is quite basic and I wanted to learn about C++ a bit in depth and cover some advance concepts. So is this book a good choice for that??
@齐峰-l8x2 жыл бұрын
@@asdomain4503 If you have a basic understanding of object-oriented and generic programming. Maybe you don't have to read this book. The cpp specification in this book is up to cpp11, which is what other developers often call cpp2.0 or modern cpp. If you want to learn more about the usage of cpp, sorry that I may not be able to give you advice, I am also a beginner.🤯
@asdomain45032 жыл бұрын
@@齐峰-l8x got it👍...Thanks for the replies
@thePolyguru Жыл бұрын
This video was totally awesome! It really helped me understand the aspects of multi-threading, and how to properly implement it. Will help with my engineering degree for sure!
@trtlphnx3 жыл бұрын
Thanks You For Such an Ingenious, Creative Presentation; You Are My Favorite Channel Here On The "Tube" ~ Love What you Are Doing, Please NEVER Stop ~
@amit6k2 жыл бұрын
Hi Saldina, Thanks for the video. I tried to execute the example you have shown with VSCode, the compiler used was Clang++ together forming an IDE that is different to visual studio. Here is what you miss at the end: worker1.join() worker2.join() Above to statementst are essential to my IDE because, without them, the execution control just spawns the threads and exits. Therefore, i cannot see the results. Instead the join operator tells the execution control to wait until the worker1 and worker2 is completed. By this way you overcome the dependency on the visual studio IDE.
@omkarchavan46442 жыл бұрын
thanks....this solved my problem too.
@SauravKumar-vj7ks3 жыл бұрын
This was such a mindd blowing video with clear, concise and awesome explanation. Thanks saldina, you're just amazing. And yesss, please continue telling more about the bugs, programming issues with code and software development tips in general. They would be really helpful. Btw just one small suggestion, please make a video on asynchronous programming with modern C++. Keep up the great content. 👍
@mauromafra3 жыл бұрын
It is an excellent video, congratulations. You speak clearly and in an objective way, great work!
@rea1967Ай бұрын
-1°, 3:30am, varaždin also genious video! every question that popped into my mind was answered right away, thank you!! subscribed right away and went to check out your other videos. loved extra "fun facts" at the end and showing different perspective of the same solution
@gemechuuberiisoo698 Жыл бұрын
You are an astounding teacher, thank you very much!
@archanasubramanian27342 жыл бұрын
Looking forward to more concepts in multithreading. Thanks for this neat description.
@dundyd36123 жыл бұрын
I love your videos, they're the best! Great job as always ❤️❤️
@ВикторГиль-ф2ф3 жыл бұрын
Why do you love videos with big problems in examples ?
@TonyStark-lw7lv2 жыл бұрын
I think if you can understand big problems , you will automatically be able to solve the simpler ones.
@Greyhame20102 жыл бұрын
Don't know what to say, but, whoa! Jumping around KZbin trying to pick up some hidden gems buried in the C++ landscape to help me to become a better C++ programmer. The language is full of features and is continually evolving with the new technologies coming out these days, but this simple example of using threads is cool and will certainly be in my toolbox for any future projects I may have in mind. (The last time I was exposed to threads was in a Unix system and it was overly complicated and probably not worth the trouble of trying to decipher it lol.) Thanks for sharing your time and hope you get millions of views and tons of ad revenue lol 😄👍
@elprofesor61563 жыл бұрын
Eagerly waiting🎉 and kindly do upload more topics of DATA STRUCTURES🧑💻. It will be very helpful❤️😊
@powertube5671 Жыл бұрын
Thank you so much for an easy-to-understand tutorial. This example is exactly what I am looking for. I wrote a shortwave receiver control program, but in order to get signal strength readings, the reading loop has to be in a separate thread. Now all I have to do is apply this to a C++/CLI application. It will be somewhat different, but the principle is the same. I already wrote the signal strength reading function with an infinite loop like you show. It works, but has to be put in the background.
@ordinary_man_844 ай бұрын
Awesome! With my bad English I understood all in this lesson. Saldina explains very clearly.
@CodeBeauty4 ай бұрын
Thanks, welcome to my channel 🥰
@cepson2 жыл бұрын
Great video. I tried the first example using Linux and gcc and had some trouble, since I had to tell the IDE to link to a library that it does not automatically use. Then, my output was always the output of one function followed by the output of the other -- in other words, I didn't get any mixed results. After playing around with it for a while, I found that which output is printed to the console first varies from run to run. So instead of doing a loop that executed 200 times, I made a loop that executed 200,000 times. Now I get the mixed output, but there are alternating very large runs of output from the two functions. My guess (and it is a shear guess, because I am a complete novice) is that the speed of the CPU executes the two threads so quickly it doesn't need to alternate between the two threads, unless they run for a "long" time. "Long" being relative, because even with a loop that outputs a character to the console 200,000 times takes a fraction of a second to complete.
@sparshb9566 Жыл бұрын
Hello @CodeBeauty How did you get spaces in the for-loop at 4:22 ? Thanks!
@LimaSentosa2 жыл бұрын
This is very useful and relevant because I use Visual C++ 2019. Many sources are created for C++ 11 which cannot be run using Visual C++ 2019. Thank you very much !
@Ghisisan_3 жыл бұрын
Nice video! It is well and simple explained. Multithreading is definitely a subject I want to hear more about. Looking forward for your future videos.🤗
@janeikeliu Жыл бұрын
Fantastic and easy to understand explanation of multithreading in C++! Thank you!
@yahee832 жыл бұрын
The best C++ teaching ever
@shashankcool2 жыл бұрын
Thanks Saldina for explaning thread concept in c++ with simple example. Awaiting more such videos in C++.
@marym90033 жыл бұрын
Thanks for the Linode gift, it is very useful 💜💜
@alterratz6653 жыл бұрын
It should probably be: void RefreshForcast(std::map& forecastMap) and std::thread bgWorker(RefreshForcast, std::ref(forecastMap)); Other wise I liked your video. 👍
@matrix_74823 жыл бұрын
Gledao sam nekoliko klipova sa ovog kanala, medjutim u ovom klipu si pomenula "Mostar" (Prelazim na "ti" u komentaru). Nakon toga sam usao na opis kanala i shvatio da si iz BiH, tacnije Mostara. Iskreno, pozitivno sam iznenadjen, da postoji ovako uspjesan youtube kanal vezan za programiranje (pogotovo u C++) u BiH. Samo tako nastavi, veliki pozdrav iz Banja Luke. 😁
@gurpartapsingh88812 жыл бұрын
i think we can see this type of problem which u mentioned in like most mobile applications in which they ask for permission for sunning in the background, what I think we can make it something like whenever the application is opened it will start the process of getting the data and continue to refresh the data till the user is using the application and stop whenever it is closed. If I am wrong or correct pls do tell and if u have suggestions. i am new to programming.
@aryansharma99333 жыл бұрын
You are doing great work ✨ 💜
@nickoppen3 жыл бұрын
Hi Saldina. Excellent videos, especially this one. The last time I did any multithreading it looked like this: fork(void *). Now you've brought me up-to-date in 27 minutes and 12 seconds. Could you also do a video on how modern C++ does thread coordination. I always found that to be the trickiest part. Thanks, nick
@nickoppen3 жыл бұрын
@@kotarino What I used was the MFC call AfxBeginThread(runner, ((LPVOID)(*nodeI)), THREAD_PRIORITY_BELOW_NORMAL); where UINT runner((LPVOID) arg); is the function but this was a later translation of a system I wrote in 2002 for BeOS which was: spawn_thread(runner, "Name", B_NORMAL_PRIORITY, *arg);. I was trying to keep it brief.
@kesav62852 жыл бұрын
Isn't the bgWorker a single thread that is running infinitely? Because you just created only 1 thread named bgWorker and that is running infinitely right? Whereas in the first example you created 2 threads named worker1&2 so I thought that means 2 threads are created or did I understand it completely wrong?
@nv9usb3813 жыл бұрын
Thank you Saldina ❤
@mdasadazam61617 ай бұрын
awesome video, learnt multiple things from your video. Your video was worth spending my time.
@fadibenshadi71653 жыл бұрын
You are the best programming instructor in KZbin. Unfortunately we don't have online-payment services in my country Libya otherwise I would have sent you a lot of coffee.
@martinalcala48234 ай бұрын
Such a beauty! And I'm not only talking about the c++ Wonderful lady!
@ginsonmathew1862 жыл бұрын
I am eagerly waiting for the second part of this multi threading series!!!
@jammydodger1449 Жыл бұрын
Great tutorial, thanks for teaching me multithreading.
@arijitsingh10962 ай бұрын
i want to ask a question whether an application will be running multithreaded or not depends on the underlying os right ? ( the programming language is just providing us tools to write multithreaded code)?
@CodeBeauty2 ай бұрын
it mainly depends on how you write the code, meaning did you set up application to be multithreaded or not :)
@rre9518 Жыл бұрын
Code Beauty is a good name for you. Thanks! Done as simply as possible.
@Llop662 жыл бұрын
function1 doesn't seem to accept a default parameter as we're used to for any "regular" function !
@popamihnea66952 жыл бұрын
Hello, sorry if my question sounds dumb. I do not understand exactly what part of the application shows the aspect of "multi" in multithreading. To me, it seems like there is just one thread that executes the function. Thank you
@nguyenminhhoang61988 ай бұрын
I'm using the script following your instructions but there is an error that "error: 'thread' is not a member of 'std' std::thread thread1(func1); although I always include the thread lib . please help me
@pejman911 Жыл бұрын
Hello.I get the following error when I run your first code(5:45) "Debug Error -Abort() Has Been Called ".Could you guide me ?
@TxMxMxMxM3 ай бұрын
Thanks for the awesome tutorial. One question, what happens when you have more threads than the number of cores/threads in the cpu?
@CodeBeauty3 ай бұрын
When you have more threads than CPU cores, the CPU shares its time between the threads by rapidly switching between them. This is called time-slicing. Each thread gets a small amount of time to run before the CPU moves on to the next one. This process, called context switching, adds some extra work for the CPU, which can slow things down if there are too many threads. - If there are a few extra threads, the performance impact is usually small. - If there are a lot of threads, the CPU can become overwhelmed, especially if the threads are all doing heavy processing. However, if some threads are waiting for input/output (like from a file or the internet), they won’t burden the CPU much, so you can run more of them without a major slowdown.
@TxMxMxMxM3 ай бұрын
@@CodeBeauty Thanks for the fast response.
@mmaranta785 Жыл бұрын
Great stuff. How can I debug a program that I can’t end a process, except by rebooting?
@gurudatt-shahane3 жыл бұрын
Thank you for the great content, this video is awesome in explaining multi-threading 💞
@steinis64093 жыл бұрын
Was a perfect opporturnity to show-off "thread-locking" instead at the point you explained the ++++ and ---- coming in a random order.~
@cmnikola5 ай бұрын
What program do you use for screenshot? I use default windows(shift + win + s), but i want to see size of my screenshots, i hope you understand me xD 7:20
@Fernando-du5uj Жыл бұрын
Perfect explanation. Thank you alot!
@bharathadrikatteshankarapp98132 ай бұрын
Hi !!As you mentioned 2 cores running at same time is multi tasking right ? In a single core multiple threads running is multi threading right .
@CodeBeauty2 ай бұрын
Yes, that's correct! Multitasking refers to a system's ability to run multiple processes at the same time. If you have two cores running simultaneously, that's an example of multitasking because each core can handle a different task concurrently. Multithreading involves running multiple threads within a single process. On a single core, multiple threads can share the core's resources, allowing them to execute in a way that makes it seem like they are running simultaneously, even though only one thread is active at any given moment.
@FrostGamingHype2 жыл бұрын
you can use _getch(); instead of using system("pause > nul"); its more efficient to use the _getch();
@cheggmi36373 жыл бұрын
Yet another educative tutorial. I want to thank you for the time and efforts put into this. I just have a question an that is, where does the likes of atomic, mutex and so on come in where doing multithreading. How are they used and what do they do in threading? Thank you.
@azodeelvischidera48 Жыл бұрын
please the std you use while pointing our map, can't it not be declared as using namespace std? std::map I don't understand
@CoolDude911 Жыл бұрын
For me it would throw an exception when the program ran without detaching or joining the thread. i.e. bgWorker.detach(); // runs thread in background and continues to run bgWorker.join(); // waits for thread to complete
@gundam7463 Жыл бұрын
My program crash, if I do not put .join(); at the end of main, for each std::thread that I created.
@luchiha4432 жыл бұрын
Can anyone help me out. I am getting this error in my Visual Studio Code namespace "std" has no member "thread" But not in the Visual Studio. I have updated the minGW and other programs related to C++11 standards are working but not this one. Kindly help
@setripper Жыл бұрын
hello, very informative video. however, I am kind of confused on how this is different from using just one thread. I believe we can still do this with one thread by just making that map and then just calling refresh forecast.
@adityaraghav86932 жыл бұрын
This is actually good content subbed :)
@michaeldeoz3 жыл бұрын
could you explain how to interchange data between thread and main program and between threads
@MrZlocko Жыл бұрын
When I saw CodeBeauty, I thought: Here's another stupid "How to write beautifully formatted code" video .... But when I watched some of your tutorials, I was blown away .... Excellent work and excellent presentation
@GMP932 жыл бұрын
What happens if my CPU has 4 threads and I create 100 "software" threads? The operating system split them to work just in 4 CPU threads? It seems to be "fake" threads? What about performance in this case?
@shankarghimire44922 жыл бұрын
Wow! What a amazing video! Best tutorial I have ever seen on Multithreading in C++! Thank you so much for sharing your knowledge with the world! 1 Subscribe has been added! :)
@HH-mw4sq2 жыл бұрын
Shouldn't function 1 have been: void function1(const std::string &symbol) { for (int i = 0; i < 200; i++) { std::cout
@ioexec3 ай бұрын
Thank you for the simple explanation :)
@CodeBeauty2 ай бұрын
Glad it was helpful!
@vivek_agarwal2 жыл бұрын
Why is Berlin printed first in console output, but not New York ?
@anupnadagouda82403 жыл бұрын
Hi, I want to develop an application to perform laptop functions ( BIOS detail, hibernate, USB port etc) and it suppose to generate text file is it possible with C++
@kanthichandra8983 жыл бұрын
Please make Data structures too !
@bashiraddean-mufarreh6 ай бұрын
Where is the list menu for another tutorial plz
@anxonpues60183 жыл бұрын
Congratulaciones, for al your vídeos, but specially the last sentences of this one. This is REAL TEACHING transmit not only the good strengths and the weakens ... I really feel like listening one of the best doctors who teach analytical chemistry in the far 1972 !!! I remember I had been in Mostar the last summer before the division of Yugoslavia. ... well I liked places Postojna Jama. Plitvitce Yesero ... Neretva River. Island who has no vowel in the name. .... the one who produce the stones to build up White House maybe .... I would like to share with you some of the programs I wrote with your help. ... if that doesn’t represent to you to sleep even less ! 4 am and still awake. I remember doing that when young. ...now at 8 pm my body don’t work more... I repeat CONGRATULATIONS from Cardedeu Barcelona Catalonia EVG
@MaiNgocDoan18093 жыл бұрын
thank you for sharing your knowledge. I appreciate that hope you give us more video like that
@arusikapinyan6326 Жыл бұрын
❤Thank you Saldina, you are the best❤❤❤
@vishwamit2 жыл бұрын
Hi Saldina, Thank you for all your videos and doing such a great job in making them. They are extremely very easy to follow and learn. One thing I would like to know is, would ever like to add video on Linux Socket programming for Server/Client interaction in C++. It would help a lot. Thank you in advance.
@ng37733 жыл бұрын
Hi Salina, dont you need to worker1.join(); and worker2.join();?
@lawniczakjohn Жыл бұрын
Love this! Awesome video.
@testusersg2 жыл бұрын
How come your program never throw an error w/o calling "worker1.join()"?
@krishnarai21562 жыл бұрын
how to print + - + - + - pattern in your function1 and function2 code, can we do it? @CodeBeauty
@elias_polanco2 жыл бұрын
I got this error when I run the code after bieng compiled with my g++ compiler terminate called without an active exception Aborted (core dumped) what happen?
@krzysztofturchan5355 Жыл бұрын
I think you have already find the solution, but maybe it is a problem for someone else. So here is the solution: std::thread worker1(function1); worker1.join(); // -- You have to use a function join() on this thread function, and it will work well.
@zepeuf2 жыл бұрын
Hello, at the beginning you speak about the difference between multi-tasking and multi-threading... So, the solution you explain is mult-tasking, so it can be executed on 2 processors in parallel? But... What about fork()? I wrote my program with fork(), but apparently "thread" would be better for my way of exchanging data, but I want to have both "threads" run on different processors... You're the only one I found saying that multi-threading can be executed on different processors, I need your help :) Also, thanks for your really nice, clear and understandable tutorials, please continue :)
@chrisdahms96823 жыл бұрын
Great beginner thread vid, but more on other topics would be helpful (.join, semaphores, mutexes, etc)
@johnsknows3135 Жыл бұрын
thx a lot for another great video!
@leoavecesentiendo3 жыл бұрын
What a charming person! Thanks for the effort and useful information! Question: What about managing resources locally for solving a very large computational task in several threads concurrenly to make it faster for example? And the implications in memory to consider? Some sort of searching or sorting in a large matrix comes to mind... Thank you in advance!