Thread: What's a good multiplatform C++ thread solution?

  1. #1
    Ethernal Noob
    Join Date
    Nov 2001
    Posts
    1,901

    What's a good multiplatform C++ thread solution?

    Are there any multiplatform libraries for threads to be used with C++? If not I don't mind windows specific ones, but in general what are good multithreading solutions for C++/C?

  2. #2
    Deathray Engineer MacGyver's Avatar
    Join Date
    Mar 2007
    Posts
    3,210
    pthreads might be something that you want. There should be a "pthreads for Windows" library floating around.

  3. #3
    Ethernal Noob
    Join Date
    Nov 2001
    Posts
    1,901
    cool, thanks. Nice avatar btw. I'm learning Threads with Java but since I do my personal and hobby Programs in C++ I'm more interested in this for the long run.

  4. #4
    Registered User
    Join Date
    Oct 2005
    Posts
    88
    Boost::threads is probably the best around though: you don't have every facility of pthreads, but it works on more platforms/compilers than anything else (I think).

  5. #5
    Ethernal Noob
    Join Date
    Nov 2001
    Posts
    1,901
    *has flashbacks of trying to build boost*

    MAKE IT STOOOOP.

    It was more hastle than it should have been.

  6. #6
    Registered User
    Join Date
    Jan 2005
    Posts
    7,366
    Do you need to build boost to use the threads library? Most of the boost libraries don't require a build, although I guess the threads one would be more likely than others to require it.

    There was a post made a while ago, either here or on the Tech board, that had a nice explanation of how to build Boost. If you haven't already seen it, it might help.

  7. #7
    Ethernal Noob
    Join Date
    Nov 2001
    Posts
    1,901
    I don't know, I hate dealing with building libraries, they are just so annoying.

  8. #8
    Frequently Quite Prolix dwks's Avatar
    Join Date
    Apr 2005
    Location
    Canada
    Posts
    8,057
    I don't know, I hate dealing with building libraries, they are just so annoying.
    I had a lot of trouble building boost too . . . on the first computer I compiled it on, I ran out of disk space (not a good sign). The next computer I tried compiling it on had an incompatible environment of some sort (I don't remember what was wrong with it), so I got to compile each source file by hand. It wasn't fun . . . and after all of that I never use it.

    pthreads work quite well, even on Windows (for which you usually use winsock2). I recommend them.
    Last edited by dwks; 03-30-2007 at 03:10 PM.
    dwk

    Seek and ye shall find. quaere et invenies.

    "Simplicity does not precede complexity, but follows it." -- Alan Perlis
    "Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
    "The only real mistake is the one from which we learn nothing." -- John Powell


    Other boards: DaniWeb, TPS
    Unofficial Wiki FAQ: cpwiki.sf.net

    My website: http://dwks.theprogrammingsite.com/
    Projects: codeform, xuni, atlantis, nort, etc.

  9. #9
    Ethernal Noob
    Join Date
    Nov 2001
    Posts
    1,901
    Anyone heard of ztheads.

  10. #10
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,895
    Boost.Threads requires building.
    Strangely enough, I never had any problems building Boost. I downloaded it, unpacked it, ran the commands and it worked.
    All the buzzt!
    CornedBee

    "There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
    - Flon's Law

  11. #11
    Ethernal Noob
    Join Date
    Nov 2001
    Posts
    1,901
    can you build only certain parts of boost rather than the entire thing.

  12. #12
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,895
    Yes, but that's more complicated.

    (All right, so it mostly means being in a different directory when typing the bjam command. That's one way, at least.)
    All the buzzt!
    CornedBee

    "There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
    - Flon's Law

  13. #13
    Ethernal Noob
    Join Date
    Nov 2001
    Posts
    1,901
    *hears bjam*

    *snap*

  14. #14
    Officially An Architect brewbuck's Avatar
    Join Date
    Mar 2007
    Location
    Portland, OR
    Posts
    7,396
    Quote Originally Posted by CornedBee View Post
    Boost.Threads requires building.
    Strangely enough, I never had any problems building Boost. I downloaded it, unpacked it, ran the commands and it worked.
    I've compiled Boost on an ancient (20 MHz I think) PA-RISC system before. It took 3 days to finish. Just compiling the regex part took 7 hours.

  15. #15
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    I downloaded it, unpacked it, ran the commands and it worked.
    Sadly, I downloaded it, unpacked it, ran the commands and it Jammed
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 2
    Last Post: 07-01-2007, 07:11 AM
  2. Thread Synchronization in Win32
    By passionate_guy in forum C Programming
    Replies: 0
    Last Post: 02-06-2006, 05:34 AM
  3. Thread confusion
    By pyrolink in forum C Programming
    Replies: 0
    Last Post: 01-29-2006, 09:42 PM
  4. Problem : Threads WILL NOT DIE!!
    By hanhao in forum C++ Programming
    Replies: 2
    Last Post: 04-16-2004, 01:37 PM
  5. How to make a thread sleep or std::recv timeout?
    By BrianK in forum Linux Programming
    Replies: 3
    Last Post: 02-26-2003, 10:27 PM