Multithreading in C++

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Man4ish
    New Member
    • Mar 2008
    • 151

    #1

    Multithreading in C++

    I am plannning to learn multithreading in C++.I have 2+ years of exp in C++. Is it easy or difficult?

    Regards
  • Banfa
    Recognized Expert Expert
    • Feb 2006
    • 9067

    #2
    There is no multi-threading in C++ multi-threading is a platform feature outside the C++ standard.

    That said it is normally fairly simple, write a function that will be the entry point of your thread, call a function to create the new thread.

    You have to be careful in Windows that has several different functions you can call all of which do slightly different things.

    You must also be careful about data access, if a thread is writing to a variable then you must ensure no other thread is reading or writing to the same variable.

    Thread synchronisation objects like mutexs and semaphores which generally exist on most platforms that have multi-threading. Some platforms have additional synchronisation objects such as events and critical sections on Windows.

    Comment

    • jkmyoung
      Recognized Expert Top Contributor
      • Mar 2006
      • 2057

      #3
      Whether you find it easy or difficult will depend on what you will be specifically doing with the threads, particularly the amount of interdependence of the threads. If there is no interaction between threads, it is typically pretty easy.

      If you start getting into Producer/Consumer scenarios, then the threading becomes a little more complicated. Starting with the most basic of basic multi-threading will help you in the long run.

      Comment

      Working...