Multithreading In C++

แชร์
ฝัง
  • เผยแพร่เมื่อ 20 ม.ค. 2025

ความคิดเห็น • 310

  • @cid007007
    @cid007007 4 ปีที่แล้ว +33

    I crosschecked many times and pasted your code also but same result... With thread.. it takes 13 secs but Without thread it takes 10 secs.. how ?????

    • @CppNuts
      @CppNuts  4 ปีที่แล้ว +2

      Did you took latest code i updated in video details.
      I have provided link.

    • @cid007007
      @cid007007 4 ปีที่แล้ว +1

      @@CppNuts Yes rupesh... latest one from link where you are passing reference of OddSum and EvenSum instead of making them global variable....

    • @CppNuts
      @CppNuts  4 ปีที่แล้ว +1

      Then no idea why is it like this.
      I have 3 system i check in every system but not getting this issue.

    • @likethat111
      @likethat111 4 ปีที่แล้ว +7

      The problem here simple addition is being used +. Load on the CPU is decided based on machine instructions finally. Replace + with say sin(i) function. Then we can say the advantage of thread parallelism over single. I tested and it is working. Also when trying with sin function, reduce last to 190000000(or have floats) otherwise it might take lot of time.

    • @sebasman1000
      @sebasman1000 4 ปีที่แล้ว +22

      creating a thread is quite an CPU intensive task. So for simple straight forward functions on an older CPU is not always faster when threaded

  • @CppNuts
    @CppNuts  5 ปีที่แล้ว +16

    Hi guys,
    Hope you enjoyed the video, more advance video is coming in few days on thread topic.
    And please let me know if i can provide something else on this topic.
    Your support is appreciated.
    LIKE & SUBSCRIBE for more videos like this.

    • @WithHumble
      @WithHumble 5 ปีที่แล้ว +1

      Your efforts are really appreciated and is helpful for many of us.

    • @CppNuts
      @CppNuts  5 ปีที่แล้ว

      @@WithHumble Thanks man, it really motivates to create more videos.

    • @s-a-k-e1814
      @s-a-k-e1814 5 ปีที่แล้ว +1

      Hi, I have two questions... can I run the same function with different threads (at the same time obv)?
      And how should I manage the return of my function? ( something like this "result= thread t0(example,1); " ? )

    • @CppNuts
      @CppNuts  5 ปีที่แล้ว +2

      That comes with future and promise topics in cpp, i will start soon.

    • @s-a-k-e1814
      @s-a-k-e1814 5 ปีที่แล้ว

      @@CppNuts thanks, I need it so much... :) Anyway why didn't you used "using namespace std;" it is so useful...

  • @nitishjaiswal
    @nitishjaiswal 5 ปีที่แล้ว +13

    Explained in simple way. Way better than other multi-threading tutorials. Kudos to you guys.

    • @CppNuts
      @CppNuts  5 ปีที่แล้ว +2

      Thanks man!!

  • @edwin3928ohd
    @edwin3928ohd 5 ปีที่แล้ว +8

    Thank you for the step-by-step instructions. I did not understand other videos, but you kept it simple and now my program runs in 1:17 and not 5:40. (4 threads) Thank you!. Subbed

    • @CppNuts
      @CppNuts  5 ปีที่แล้ว +5

      Great.. Things like this encourages me like anything.. 😍🤓

  • @daisy-bot-py
    @daisy-bot-py หลายเดือนก่อน +1

    This is quite interesting!! It took 6 sec on my computer without threading, and with threading, it took 3 sec. Thank you so much for the tutorial.

  • @jk_surums
    @jk_surums 18 วันที่ผ่านมา

    This was so high quality, simple and understandable. Bro, you should teach somewhere, u are gifted.

  • @NotJaazmine
    @NotJaazmine ปีที่แล้ว +1

    thank you! you’ve explained this so well. feeling more confident about threads already

  • @chavhanshrihari3461
    @chavhanshrihari3461 4 ปีที่แล้ว +2

    Amazing Rupesh... This i would call a social service....Keep it up... Clear cut explanation. God bless you...

    • @CppNuts
      @CppNuts  4 ปีที่แล้ว

      Thanks man..

  • @ManjunathJanardhan
    @ManjunathJanardhan 3 ปีที่แล้ว +5

    We can use "auto duration = duration_cast(stopTime - startTime); " to get the seconds directly instead of getting in micro sec and then dividing it to get in seconds.

  • @АлексейЛавренович-х7е
    @АлексейЛавренович-х7е 3 ปีที่แล้ว +2

    I absolutely love how he drew his channel logo at the end, you're cool 😎❤️

    • @CppNuts
      @CppNuts  3 ปีที่แล้ว +2

      Thanks..

  • @digikiwam
    @digikiwam 4 ปีที่แล้ว +8

    Bear in mind, threading doesn't always mean your execution time will be faster. There are a lot of factors that can make threading even slower than serial.

    • @CppNuts
      @CppNuts  4 ปีที่แล้ว

      True..

    • @linhnguyenthithuy-st7vn
      @linhnguyenthithuy-st7vn ปีที่แล้ว

      @@CppNuts could you tell me some cases when threading is slower than others

    • @charanpreetsinghbhatia7184
      @charanpreetsinghbhatia7184 3 หลายเดือนก่อน +1

      @@linhnguyenthithuy-st7vn I can think of a scenario where we have a CPU with single core and both threads have methods which fully need CPU (no I/O). In that case total time spent = CPU time of 1st + CPU time of 2nd + buffer (due to context switches and saving overheads)

  • @khurramsaqib5890
    @khurramsaqib5890 3 ปีที่แล้ว +1

    I am using VS Code with MinGw compiler and getting the error message "thread" was not declared. I ensured to copy the code correctly, but the program is not running, any suggestions?

  • @Byynx
    @Byynx 10 หลายเดือนก่อน

    I would never thought that i would discover that with a bitwise operators i could check if a number is odd or even. This makes me wonder the world of possibilities that bitwise operators can give.

  • @nusud
    @nusud 4 ปีที่แล้ว +2

    hello, i wanted to thank you for keeping it simple! the example is great, as well as the explanation! keep it up! cheers!

    • @CppNuts
      @CppNuts  4 ปีที่แล้ว

      Thanks dude..

  • @CppNuts
    @CppNuts  4 ปีที่แล้ว +1

    There are so many questions about the program not behaving correct on different systems, so i double checked everything and found that if we pass by std::ref which i did then it is some how behaving different in some system, so i have made some changes in program, now instead of std::ref i am sending the old school address and it is working fine.
    check it out: ideone.com/ypngpe
    let me know if link is not working i will create another one.

    • @mouryas5791
      @mouryas5791 4 ปีที่แล้ว

      Hi Rupesh, with threads and without threads the execution time is same no difference,

    • @CppNuts
      @CppNuts  4 ปีที่แล้ว

      What is the configuration of your computer?

    • @mouryas5791
      @mouryas5791 4 ปีที่แล้ว

      @@CppNuts i5 processor with 8Gb of ram

    • @CppNuts
      @CppNuts  4 ปีที่แล้ว

      We have to setup program one I have explained in video and one I have given in the link so, in both the cases is it same or it's different.

    • @sab229
      @sab229 4 ปีที่แล้ว +1

      I ran the program given in the above link in Cygwin and it ran in time twice of what it took to run without the threads. More specifically the time for code with threads took 17 seconds and without threads, it took 9 seconds. Is there an issue with running threads in Cygwin?

  • @scutursula7536
    @scutursula7536 5 ปีที่แล้ว +3

    Very useful. This subject is very interesting, i hope you'll talk more about it in your next videos. Keep up with good work.

    • @CppNuts
      @CppNuts  5 ปีที่แล้ว

      Sure man, and thanks for the comment.

  • @jayantjain2210
    @jayantjain2210 ปีที่แล้ว +2

    How are you running thread in sublime text
    My sublime is giving me this error:
    In function 'int main()':
    error: 'thread' was not declared in this scope
    thread t1(temp);
    ^~~~~~
    error: expected ';' before 't2'
    thread t2(temp2);
    ^~
    error: 't1' was not declared in this scope
    t1.join();
    error: 't2' was not declared in this scope
    t2.join();
    ^~
    [Finished in 668ms]

    • @jays2144
      @jays2144 4 หลายเดือนก่อน

      bhai have you got this issue fixed?? please help me, i am also facing this issue

    • @daewanshbansal6173
      @daewanshbansal6173 3 หลายเดือนก่อน

      Im facing the same issue as well if you have already found out the way to resolve it plz help me out.

    • @jays2144
      @jays2144 3 หลายเดือนก่อน

      @@daewanshbansal6173 bro at that time instead of fixing my ide i used online gdb compiler...

  • @harounlouati6602
    @harounlouati6602 2 ปีที่แล้ว

    I really like the way how you explain things. Thank you so much.

  • @amentothatt
    @amentothatt 4 ปีที่แล้ว +1

    Very eloquently explained, great Vid. Subbed!

    • @amentothatt
      @amentothatt 4 ปีที่แล้ว

      Salutes from a Chinese fellow engineer

    • @CppNuts
      @CppNuts  4 ปีที่แล้ว +1

      Thanks dude..

  • @sahilguleria6976
    @sahilguleria6976 4 หลายเดือนก่อน

    By default, std::thread copies the arguments you pass into its constructor.
    When you use references (ull&), it tries to copy the reference.
    However, references cannot be copied-they must refer to an actual object.
    To pass references to a std::thread-launched function, you need to explicitly wrap the reference in std::ref().
    This tells the thread to pass the argument as a reference, not by copying.

  • @brajrajsingh1001
    @brajrajsingh1001 4 หลายเดือนก่อน

    Hi Rupesh,
    The Spelling of Multithreading is in-correct in the playlist. you can correct it to increase your search results. I liked your cpp lectures and would like to request more advance topics like metaprogramming ,etc more of interview questions at higher experiences related to designs. Thanks..

    • @CppNuts
      @CppNuts  4 หลายเดือนก่อน

      Hey Brajraj, in title it's correct.
      Have I missed somewhere in description?
      Thanks

  • @Sandroidus
    @Sandroidus 4 ปีที่แล้ว +4

    1. All performance testing should be done in Release. It should be mentioned. (Otherwise 2-threaded version may take longer time to execute).
    2. What is the point of duration_cast and then dividing it by 1000000 ? Why not to duration_cast ?

    • @pavelkravchenko2810
      @pavelkravchenko2810 4 ปีที่แล้ว +1

      Pls explain about the testing in Release, cuz I have this result with 2 X time 🤷‍♀️

    • @cid007007
      @cid007007 3 ปีที่แล้ว

      @@pavelkravchenko2810 I have faced same issue.. it was taking almost 2x time with 2 threads. So these are steps that resolved my issue :
      Editor -- XCode
      1) Product -> Scheme -> Edit Scheme -> Change Build Configuration to "Release"
      2) Now clean Build -> Run app
      you will get desired result shown in video.. :)

  • @rampandi9302
    @rampandi9302 5 ปีที่แล้ว +1

    Superbb explanation sir. I will never miss yr videos 😍😍😍

    • @CppNuts
      @CppNuts  5 ปีที่แล้ว +1

      Thanks for your support man!!

  • @thegoddessgeek
    @thegoddessgeek 2 ปีที่แล้ว

    question, what happens when the second thread finishes first before the first thread? will the t1.join() wait for the t1 to finsh before it can t2.join() wait for the t2? or.... both of this join() will run parallel too?

    • @CppNuts
      @CppNuts  2 ปีที่แล้ว

      Yes it will wait.

  • @AjayKumar-kg6vo
    @AjayKumar-kg6vo 3 ปีที่แล้ว

    why it is showing error like:- error: 'thread' is not a member of 'std' Can you please help on this. I am running my code on vs code and minGW compiler installed

  • @ayushmaankaul6742
    @ayushmaankaul6742 4 ปีที่แล้ว +1

    My multithreaded program took more time than sequential one. Why would that be happening?

    • @CppNuts
      @CppNuts  4 ปีที่แล้ว +1

      This should happen only when you have single core CPU. otherwise i do get comments like yours but can't really think of reasons.
      I tried myself in 3 different systems and it was giving less time while threading, so no clue, i am sorry for not been able to answer to this question.

    • @fang8660
      @fang8660 3 ปีที่แล้ว

      Apparently it depends on the system - multithreading isn't always faster for everyone depending on what you're doing.
      stackoverflow.com/questions/46759930/multithreading-slower-than-single-threading

    • @charanpreetsinghbhatia7184
      @charanpreetsinghbhatia7184 3 หลายเดือนก่อน

      @@CppNuts does CPU know to spawn the new thread in a new core for parallelism or in the same core for concurrency? How is that decided?

  • @Durgasivakumaran
    @Durgasivakumaran 3 ปีที่แล้ว

    I just love all your videos and teaching sir... Grt😍👍

    • @CppNuts
      @CppNuts  3 ปีที่แล้ว

      Glad to hear that

  • @rishisolanki-h8y
    @rishisolanki-h8y ปีที่แล้ว

    loved it, best explanation done

  • @amargandhi1137
    @amargandhi1137 5 ปีที่แล้ว +1

    Hi sir
    Can you please explain me if two threads are trying to access same code in singalton class in C++ please I humble request to you

  • @timmyxuereb3083
    @timmyxuereb3083 ปีที่แล้ว

    when you were interrupted, it was a perfect example of threading

    • @CppNuts
      @CppNuts  ปีที่แล้ว

      Yes that's correct !!

  • @sameermishra8810
    @sameermishra8810 3 ปีที่แล้ว

    showing undefined reference to pthread_creat() any idea how to tackle it... i just copied the code in vim and run `g++ -std = c++17 f1.cpp -o c1`

    • @sameermishra8810
      @sameermishra8810 3 ปีที่แล้ว

      doing in virtual machine

    • @sameermishra8810
      @sameermishra8810 3 ปีที่แล้ว

      resolved to use `g++ -std=c++17 f1.cpp -pthread -o c1`

  • @il4w
    @il4w ปีที่แล้ว

    can you explain what might be happening when I calculate the sums using the main thread print time(comes out to be 8 seconds), when I do it using the 2 threads in the same execution of the program without commenting out the main thread calculation without use of threading it takes me aroudn 11 to 15 seconds via multiple threads then weirdly .
    But if i comment out the calculation of main thread and then execute just the multiple thread calculation it does almost half the processing time for the calculation.
    So basically when I execute these two methods exclusively the multithreading results in efficiency else if I execute the 2 scenarios together in the same run the multithreading actually takes more time weirdly ??
    This was all when done with debug configuration was debug though
    when i change config to release I get almost half the execution time with multithreading based approach even when running in the same run

  • @qichengu9202
    @qichengu9202 ปีที่แล้ว

    In visual studio 2022 debug mode, multithreading does not have any speed benefits for this piece of code. Are there any experts here?

  • @tanveerasif5978
    @tanveerasif5978 4 ปีที่แล้ว

    Hi,
    In my laptop, above code is taking 46 sec and with thread 25 sec.
    any idea why this much slow ?
    Intel i7 HQ6820 @2.7Gz and RAM 48 GB

    • @CppNuts
      @CppNuts  4 ปีที่แล้ว

      I think it's fine.

    • @fang8660
      @fang8660 3 ปีที่แล้ว

      How old is it? I don't think that cpu should be performing that poorly

  • @nitigya
    @nitigya 2 ปีที่แล้ว

    Why there is need of creating 2 threads? We already have one thread main() which can do say findEven and we can create only one thread for findOdd

    • @Nohomosapien
      @Nohomosapien 2 ปีที่แล้ว

      This is a small program that just finds sum of even and odd nuns but when you are coding a large application that has billions of lines of code eg. Google(2 billion lines of code), your program should be as fast as possible and it should be able to do multiple tasks at same time.

  • @govindkothari7989
    @govindkothari7989 5 ปีที่แล้ว +1

    Well explained sir.
    Your work is appreciated

    • @CppNuts
      @CppNuts  5 ปีที่แล้ว +1

      Thanks man!!

  • @bhargavkumar5412
    @bhargavkumar5412 4 ปีที่แล้ว +1

    Hey Rupesh, which CPP editor are you using?

    • @CppNuts
      @CppNuts  4 ปีที่แล้ว

      It's VS Code.

  • @sebastienleroux3122
    @sebastienleroux3122 ปีที่แล้ว

    Not working on raspberry pi 3 :( Error from g++ undefined reference to `pthread_create'

  • @nishantdhingra5985
    @nishantdhingra5985 4 ปีที่แล้ว

    can you please tell me how to compile it? And what changes we need to make if we want to run it in .c format?

  • @ChandraShekhar-by3cd
    @ChandraShekhar-by3cd 5 ปีที่แล้ว +2

    Hello sir could u plss share some resources from where u get these things..that will be helpful

    • @CppNuts
      @CppNuts  5 ปีที่แล้ว +2

      My knowledge is from stackoverlfow. i was involved in stackoverflow and used to give answers to people and see the answers for my doubts and there were so many discussion, i learned alot from there.

    • @ChandraShekhar-by3cd
      @ChandraShekhar-by3cd 5 ปีที่แล้ว +1

      @@CppNuts Thanks for reply..but is there any specific book or sites u visited earlier in ur initial learnubg phase..if u could throw some light definetly it wud help beginners like me and all

    • @CppNuts
      @CppNuts  5 ปีที่แล้ว +2

      Duede trust me there is nomagic stick, i can tell u one thing only which might be of help.
      Decide a topic what ever it is and then fuck the internet for hunting more and more about it, thats it you are now master at that topic. Thats All!!

    • @iamravishank
      @iamravishank 5 ปีที่แล้ว +1

      There is only one website.
      Google.com
      😊😊

    • @CppNuts
      @CppNuts  5 ปีที่แล้ว

      Ravi Correct!!

  • @bhaskarchary6683
    @bhaskarchary6683 4 ปีที่แล้ว

    Where can I get all these sample?

  • @experimentalhypothesis1137
    @experimentalhypothesis1137 5 ปีที่แล้ว +1

    very good example, perfect explanation

    • @CppNuts
      @CppNuts  5 ปีที่แล้ว

      Thanks for the comment man!

  • @UtpalPodder-IITian
    @UtpalPodder-IITian ปีที่แล้ว

    can anyone help to debug this below error
    error: 'thread' is not a member of 'std'

    • @CppNuts
      @CppNuts  ปีที่แล้ว

      How r you compiling?
      Command ?

  • @mokera3801
    @mokera3801 5 ปีที่แล้ว +1

    which compiler are you using?
    I am using MinGW and it's showing an error :(

    • @mokera3801
      @mokera3801 5 ปีที่แล้ว +1

      on Windows 10

    • @CppNuts
      @CppNuts  5 ปีที่แล้ว

      Error?
      Can you paste it?

    • @deepjyotsinghkapoor1955
      @deepjyotsinghkapoor1955 4 ปีที่แล้ว

      Did you got the error?
      I am also getting error on using thread

    • @daewanshbansal6173
      @daewanshbansal6173 3 หลายเดือนก่อน

      @@CppNutsHi, im getting this error:
      “Thread is not a member of ‘std’ “. Please help me out with this problem thought my Mingw complier is also up to date that supports C++11 version.

  • @mizel_almizel
    @mizel_almizel 3 ปีที่แล้ว

    i need implementation thread and fork can you help im looking someone implement i need understand how its work please help

  • @sony1979iq
    @sony1979iq 4 ปีที่แล้ว

    ok.. but after we make threading, how many thread did the program made? is it parent thread main() and 2 child threads?

  • @higgs.boson.0
    @higgs.boson.0 10 หลายเดือนก่อน

    what specification were you using?

  • @alfoom6922
    @alfoom6922 3 ปีที่แล้ว

    Great video. Greetings from Spain

    • @CppNuts
      @CppNuts  3 ปีที่แล้ว

      Thanks

  • @adityasahu96
    @adityasahu96 3 ปีที่แล้ว

    getting error like this, using c++17
    error: 'thread' is not a member of 'std'

  • @sebasman1000
    @sebasman1000 4 ปีที่แล้ว

    hey man, absolutely love your explanations video's. But if I can give you 1 tip, make your intro sound a little less loud. You have a very calm soft voice, so during the video I turn my volume up but when another video starts playing from your playlists I almost go deaf from your intro sound. But keep up the good work, loads of love from a jr. developer in holland

    • @CppNuts
      @CppNuts  4 ปีที่แล้ว

      I was wonder if that is an issue. Thanks for the tip.

  • @clashwithdheeraj1599
    @clashwithdheeraj1599 3 หลายเดือนก่อน

    very nice and simple explanation

  • @nageshtuppad6736
    @nageshtuppad6736 5 ปีที่แล้ว +3

    I wrote exactly same code visual studio
    its taking 21 seconds without thread concept
    by using 2 separate threads as you did its taking double 40 seconds..
    its happening ulta...

  • @vvpChannel3112
    @vvpChannel3112 3 ปีที่แล้ว

    Sir What happens if a Thread finishes before OS calls Join( ). Does Thread joins the main program even in that situation ?

  • @МехмедГрош
    @МехмедГрош 5 ปีที่แล้ว

    Hi,
    I have un issue. My programme needs 12 sec to execute without threads and 19sec to execute with threads. Can somebody explain me why?

  • @chandravirsingh1184
    @chandravirsingh1184 5 ปีที่แล้ว +2

    Hi Sir, which IDE you used in video's? I am looking the same IDE ? is it available for Windows or Mac?

    • @CppNuts
      @CppNuts  5 ปีที่แล้ว +1

      I have used Sublime text editor 3.
      But this is editor you will have to link compiler with it.
      And it available in mac n windows both.

  • @himalayasinghsheoran1255
    @himalayasinghsheoran1255 4 ปีที่แล้ว

    Hi, I have an issue program without use of thread takes 8sec and the one with thread takes 13-17 sec. My laptop have an i5-9300H processor.

    • @CppNuts
      @CppNuts  4 ปีที่แล้ว

      There are so many questions about the program not behaving correct on different systems, so i double checked everything and found that if we pass by std::ref which i did then it is some how behaving different in some system, so i have made some changes in program, now instead of std::ref i am sending the old school address and it is working fine.
      check it out: ideone.com/ypngpe
      let me know if link is not working i will create another one.

    • @srinu571
      @srinu571 4 ปีที่แล้ว

      @@CppNuts This link is not working

    • @Sandroidus
      @Sandroidus 4 ปีที่แล้ว

      You're running in debug mode. Switch to release

  • @awaisnawaz2791
    @awaisnawaz2791 3 ปีที่แล้ว

    Can you please tell me which IDE this is?

  • @bhagwatjadhav94
    @bhagwatjadhav94 5 ปีที่แล้ว +1

    Hi just found your channel. thanks man lovin it.

    • @CppNuts
      @CppNuts  5 ปีที่แล้ว +1

      Thanks man, i am out of station, next threading video will come around next week.

  • @avadhpatel111
    @avadhpatel111 4 ปีที่แล้ว

    Beautifully explained!

    • @CppNuts
      @CppNuts  4 ปีที่แล้ว

      Glad you think so!

  • @rajeevdas8213
    @rajeevdas8213 5 ปีที่แล้ว +1

    Do you have any video on thread that explains thread scheduling techniques

    • @CppNuts
      @CppNuts  4 ปีที่แล้ว

      No, i may have in future, thanks for the topic.

  • @sagardeka2158
    @sagardeka2158 4 ปีที่แล้ว

    sir I wrote the same code, I gave start=0, end=2000000000 (=2B)
    but in my case multithreaded code took 37 seconds wherease normal code took 28 second....why?

  • @milan_shah
    @milan_shah 4 ปีที่แล้ว +3

    Thanks for making this video. It was very helpful.
    However, when I ran the code, shown in the video as well as mentioned in the above link, it takes more time when use thread compared to when I don't. For example, for the code mentioned at the above link, it takes 7 seconds to execute the code with threading; while it takes 6 seconds when I'm not using threading!! (I'm running the code using VSCode in Ubuntu 16.04)
    Do you have any idea? Why it's happening?
    Thanks again :)

    • @lucidlynxxx
      @lucidlynxxx 3 ปีที่แล้ว +1

      same prob with me...

    • @lucidlynxxx
      @lucidlynxxx 3 ปีที่แล้ว +1

      and its also giving this output OddSum 950000000
      EvenSum 950000001

  • @prajwaldeepkhokhar7416
    @prajwaldeepkhokhar7416 3 ปีที่แล้ว

    Sir i have a question, lets say we have 10 threads and we want them to be able to pick up a job dynamically, (assuming we have 15 callable functions), how can we dynamically pass the name of functions and parameters? Do threads accept function names stored in variables?

  • @bhargavpatel4781
    @bhargavpatel4781 4 ปีที่แล้ว

    Sir what is idle trigger

  • @EschoolIsrael
    @EschoolIsrael 2 ปีที่แล้ว

    how can i send you email with something related to patreon? different offer

    • @CppNuts
      @CppNuts  2 ปีที่แล้ว

      You can mention here

  • @shruthiv4566
    @shruthiv4566 4 ปีที่แล้ว

    Very nice series. Please continue to make some great content. Can you make a series on ipcs n socket programming

  • @nitinverma1421
    @nitinverma1421 5 ปีที่แล้ว

    Explanation was great that helps keep doing good work thanks

    • @CppNuts
      @CppNuts  5 ปีที่แล้ว

      Thanks for the encouragement dude!!

  • @ka-hp4qf
    @ka-hp4qf 2 ปีที่แล้ว

    Excellent vedio which can be easily understood

    • @CppNuts
      @CppNuts  2 ปีที่แล้ว

      Thanks

  • @fenikatharotiya4333
    @fenikatharotiya4333 ปีที่แล้ว

    very much nicely explained !!

  • @AmitParopkari
    @AmitParopkari 4 ปีที่แล้ว

    wow, this is really nice demo & explanation, thanks

    • @CppNuts
      @CppNuts  4 ปีที่แล้ว

      Thanks dude..

  • @abelashenafi6291
    @abelashenafi6291 ปีที่แล้ว

    You're just awesome mate. Thanks a lot

  • @黎銘-s9n
    @黎銘-s9n 4 ปีที่แล้ว +3

    you said it, I love C++! And I love Hindi!

  • @ghostknight3175
    @ghostknight3175 3 ปีที่แล้ว

    my M1 Mac is taking 8 see without thread and 2 sec with thread why?

    • @CppNuts
      @CppNuts  3 ปีที่แล้ว

      It is good right?

  • @antonfernando8409
    @antonfernando8409 3 ปีที่แล้ว

    C++ threading class may be cool, but nothing like using the native Linux pthread_create() like POSIX APIs to manage your threads, also note that not all thread related services are in the c++ class, for example, pthread_cond_wait(), signal and broadcast APIs which helps a producer thread to wake up waiting consumer threads. Perhaps in the case of writing highly portable c++ code, might be useful to use the thread class. any thoughts?

    • @CppNuts
      @CppNuts  3 ปีที่แล้ว

      If portability is what you need the most then you can go with C++ otherwise POSIX is great choice.

  • @pk471
    @pk471 3 ปีที่แล้ว

    sir how to get these code?

  • @teetanrobotics5363
    @teetanrobotics5363 4 ปีที่แล้ว +1

    Please make tutorial on C++ boost library. There aren't many tutorials online and also your channel focuses on C++

  • @amargandhi1137
    @amargandhi1137 5 ปีที่แล้ว +1

    Can you provide me the video on spin lock in thread

    • @CppNuts
      @CppNuts  5 ปีที่แล้ว +1

      Sure, wait for some time.

  • @srinu571
    @srinu571 4 ปีที่แล้ว +2

    I am surprised by seeing the result in my VS2015, without threads it took 9secs and with two threads it took 20Secs for the same program.It's strange..

    • @CppNuts
      @CppNuts  4 ปีที่แล้ว

      Please check the code link in description field.

    • @srinu571
      @srinu571 4 ปีที่แล้ว +1

      @@CppNuts ​ Even with this new code (Passing evensum and odd sum address and taking as pointer in functions) taking more time 28 sec

    • @CppNuts
      @CppNuts  4 ปีที่แล้ว

      @@srinu571 No idea about visual studio, i have verified in Mac and Linux.
      May be some day i will run using visual studio and see if there is something i can do to overcome this.

    • @Sandroidus
      @Sandroidus 4 ปีที่แล้ว

      switch to release. never check performance in debug mode.

    • @bemb_111akshaychaudhari8
      @bemb_111akshaychaudhari8 หลายเดือนก่อน

      In the single-threaded version, the entire task is performed on a single thread without the overhead of managing additional threads. The CPU executes instructions sequentially without the need to switch contexts or synchronize memory.

  • @vijayasajwan2830
    @vijayasajwan2830 5 ปีที่แล้ว +1

    Can you Share the link (GitHub/any other URL) for the code used in the vedio. Is there any vedio for C++20?

    • @CppNuts
      @CppNuts  5 ปีที่แล้ว

      I have started writing, will post ASAP it is done.
      No i don't have c++20 video for now but will cover it in near future.

  • @andreiasimas2984
    @andreiasimas2984 2 ปีที่แล้ว

    Hi, guys. In QtCreator it only works in release mode. If you put debug mode you will see a bigger time.

  • @akashtiwari78059
    @akashtiwari78059 ปีที่แล้ว

    you explaination is unbaeatable

  • @nandhannandhan8155
    @nandhannandhan8155 4 ปีที่แล้ว +1

    Font not clear with black background.

    • @CppNuts
      @CppNuts  4 ปีที่แล้ว

      So sorry to hear that!!

  • @TheLordoftheDarkness
    @TheLordoftheDarkness 4 ปีที่แล้ว

    Ok so I'm having some weird behavior in here. I tried the non-threaded program and it executed in 11 seconds. I then tried the threaded program and it went to 15 seconds. I then tried to change the program so oddSum and evenSum are local variables passed by pointer (the rectified version posted in the comments) and now the program sometimes executes in 13 seconds and sometimes in 6.3 seconds.
    So first why did the first multithreaded program execute slower than the non-threaded program ? Second why did the change from global to local variables change the execution time ? And finally why would the rectified program have different execution time even though it's the same executable file ?
    If it helps I'm running on Linux on a computer with an i3 processor (it should be 4 logical cores).

    • @Sandroidus
      @Sandroidus 4 ปีที่แล้ว +1

      You're running in debug mode. Switch to release

    • @TheLordoftheDarkness
      @TheLordoftheDarkness 4 ปีที่แล้ว

      @@Sandroidus Hey thank you. I just tried with -O2 and -O3. -O2's execution time is now around 4 seconds while -O3 is around 3.8 seconds.
      Thank you so much.

  • @exploringlife9323
    @exploringlife9323 ปีที่แล้ว

    it takes double time after thread ???

    • @CppNuts
      @CppNuts  ปีที่แล้ว

      Check other comments

  • @nikhilkontam9988
    @nikhilkontam9988 2 ปีที่แล้ว

    Can you please create interview question series on threading?

  • @editprousama
    @editprousama 5 ปีที่แล้ว +2

    Can you make a video on gui in C++ ?
    really need it thanks

    • @CppNuts
      @CppNuts  5 ปีที่แล้ว +2

      I never worked on GUI in c++, so it will be little hard for me.
      I have worked but with QT and that was very basic, won't help much here.

    • @toutsujet
      @toutsujet 5 ปีที่แล้ว

      @@CppNuts make video of qthead

  • @everythingcelebrity6296
    @everythingcelebrity6296 4 ปีที่แล้ว

    Dude what IDE are you using?

    • @CppNuts
      @CppNuts  4 ปีที่แล้ว

      VS Code

    • @patrykpotorak4296
      @patrykpotorak4296 4 ปีที่แล้ว

      @@CppNuts on the video we can see Sublime Text, not VS Code

  • @himanshurajpal7842
    @himanshurajpal7842 3 ปีที่แล้ว

    What's your source of knowledge ? I mean what do you read , which book you follow ? Which resources you follow for learning C++

  • @yukinohana9366
    @yukinohana9366 3 ปีที่แล้ว

    Nice explaination, thank you sir

    • @CppNuts
      @CppNuts  3 ปีที่แล้ว

      Welcome..

  • @alliswell6587
    @alliswell6587 5 ปีที่แล้ว +1

    Do you know about Devise Driver Programming?

    • @CppNuts
      @CppNuts  5 ปีที่แล้ว

      No man i am from software side.

  • @shaikthouheed9158
    @shaikthouheed9158 3 ปีที่แล้ว

    With the below program the timing issue will be solved:
    The problem is passing reference in thread, If reference and pointers removed it will work.
    Below is the program
    #include
    #include
    #include
    #include
    using namespace std;
    using namespace std::chrono;
    typedef long long int ull;
    void findEven(ull start, ull end, ull EvenSum) {
    for (ull i = start; i

  • @nitinverma1421
    @nitinverma1421 5 ปีที่แล้ว +1

    can you also provide git repo link

    • @CppNuts
      @CppNuts  5 ปีที่แล้ว

      Actually i don't have git code for this video but i am planning for a website where i will keep all the code i use in videos, and that will take some time.

  • @zilola86
    @zilola86 4 ปีที่แล้ว

    finally got it!! thank you :)

    • @CppNuts
      @CppNuts  4 ปีที่แล้ว

      You are most welcome..

  • @navneeldanielpushong7743
    @navneeldanielpushong7743 4 ปีที่แล้ว

    does thread work in windows?

    • @CppNuts
      @CppNuts  4 ปีที่แล้ว

      Yes..

  • @abhishekkumar-os5ey
    @abhishekkumar-os5ey 3 ปีที่แล้ว

    I love c++ ♥️. Because,it power the world.

  • @kinkajou23
    @kinkajou23 4 ปีที่แล้ว

    thank you a lot, you're a life saver

    • @CppNuts
      @CppNuts  4 ปีที่แล้ว

      Glad it helped!

  • @dkh5944
    @dkh5944 4 ปีที่แล้ว

    Very useful content Rupesh. Can I get source code snippets explained in videos, if I join with a skilled membership.

    • @CppNuts
      @CppNuts  4 ปีที่แล้ว +1

      Yaa you will get for sure..

    • @dkh5944
      @dkh5944 4 ปีที่แล้ว

      I joined your channel as a skilled member. could you please share link for source code snippets explained in the videos. Thank you very much Rupesh.

    • @CppNuts
      @CppNuts  4 ปีที่แล้ว

      Thankss for joining the channel..
      And sure.. I will be able to give by Tomorrow..

    • @CppNuts
      @CppNuts  4 ปีที่แล้ว +1

      Do u have GitHub account, please create if not and give me userid.

    • @dkh5944
      @dkh5944 4 ปีที่แล้ว

      @@CppNuts My github userid: khasimgithub123

  • @bestganesh
    @bestganesh 3 ปีที่แล้ว

    It worked for me in Visual Studio 2019. (Code from Link in description)
    But the time take is different at every run.
    (I am running in Debug x86 configuration)
    Its 10s, 26s, 30s...

  • @ДеянЦонев-ы7в
    @ДеянЦонев-ы7в 4 ปีที่แล้ว

    Great video! Just dont know why on my pc it is slower with threads..

    • @CppNuts
      @CppNuts  4 ปีที่แล้ว

      No clue, same with other's too.
      I tested it with 3 different pc i have it was faster.

    • @Sandroidus
      @Sandroidus 4 ปีที่แล้ว

      You're running in debug mode. Switch to release

  • @shailendraprasad2190
    @shailendraprasad2190 3 ปีที่แล้ว

    Hello sir, Where do I get the source code of all of your TH-cam playlist. Will we get all source code after joining on your patreon page. Once after joining patreon, all source codes will be visible or those will be provided on request. Please let me know. Thanks for providing these amazing content video on CPP.