Results 1 to 2 of 2

Thread: Threading in C++

  1. #1

    Thread Starter
    Lively Member blackeyed's Avatar
    Join Date
    Nov 2002
    Location
    Chandigarh
    Posts
    118

    Threading in C++

    can you please let me know how to make threads in c/c++.
    ~~Avi~~

  2. #2
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    Two approaches:
    a) OS-dependent: threading is something highly OS-dependent. POSIX threads work completly different than Windows threads.
    For windows, look at the CreateThread function and related functions, as well as _beginthread and _beginthreadex. For POSIX look at clone.
    This let's you wield the full power that the OS offers, but you can't write portable code this way.

    b) OS-independent: the boost project ( www.boost.org ) has a C++ class library that offers a platform independent interface to threading. The advantage is portable code that integrates well with the C++ Standard Library. The disadvantage is that it is more or less the largest common denominator: It supports mutexes and critical sections, but not much more in the way of synchronization, and I don't know if it has thread local storage. But for simple console-based multi-threaded apps it's perfect.
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width