multi-threading tutorial

This is a discussion on multi-threading tutorial within the C++ Programming forums, part of the General Programming Boards category; I'm looking for a good simple step-by-step multi-threading tutorial.. I searched almost everywhere.. and almost in every place was a ...

  1. #1
    x4000 Ruski's Avatar
    Join Date
    Jun 2002
    Location
    Outer Space!
    Posts
    542

    multi-threading tutorial

    I'm looking for a good simple step-by-step multi-threading tutorial.. I searched almost everywhere.. and almost in every place was a different style of multi-threading so I got really confused..
    what does signature stand for?

  2. #2
    Registered User
    Join Date
    Nov 2001
    Posts
    1,348
    I highly recommend Programming Applications for Microsoft Windows (Dv-Mps General) by Jeffrey Richter.

    Kuphryn

  3. #3
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,672
    Well knowing something about your OS and Compiler would be a start.

    As would some idea of what problem you intend to solve. Threads introduce a whole raft of new problems into your code, so you really need to be solving something pretty special just of offset those difficulties.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  4. #4
    Registered User
    Join Date
    Aug 2003
    Posts
    470
    I'm looking for a good simple step-by-step multi-threading tutorial.. I searched almost everywhere.. and almost in every place was a different style of multi-threading so I got really confused..
    Some resources I've found helpful are
    http://web.mit.edu/6.826/www/notes/HO16.pdf
    http://www.flounder.com/mvp_tips.htm...esses%20series
    Any book on operating systems should cover threads, too, and there also should be a book on pthreads if you check out your local library.

  5. #5
    x4000 Ruski's Avatar
    Join Date
    Jun 2002
    Location
    Outer Space!
    Posts
    542
    I'm using Windows XP (Home) and.. most of the time Dev-C++ .. latest release.. The problem I need to solve is sockets .. I read tutorials about multiple sockets.. it has some threading.. but I couldn't understand how it works..
    what does signature stand for?

  6. #6
    x4000 Ruski's Avatar
    Join Date
    Jun 2002
    Location
    Outer Space!
    Posts
    542
    Oh.. and about my local library.. I'll barely find an old dirty fortran introduction book or maybe some basic
    what does signature stand for?

  7. #7
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,672
    > read tutorials about multiple sockets.. it has some threading
    Perhaps you read the wrong tutorials then.

    You can go one of two ways when dealing with multiple sockets.
    1. Use a separate thread for each socket.
    2. Use the select() call to tell you which socket(s) are active, and handle them appropriately.

    A lot of people seem to choose 1. because it's quick and 'cool' (using threads, yeah baby!), without having a clue about the dangers ahead.

    The argument against threads
    http://www.kuro5hin.org/story/2002/11/18/22112/860

    > but I couldn't understand how it works..
    So why not put a specific post on the network forum then?
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  8. #8
    Registered User
    Join Date
    Apr 2003
    Posts
    2,662
    ...
    if ever a feature has been easy to compare to Goto in its destructiveness, threads would be that feature. Threads are, in a sense, "the goto that keeps on giving":


    The rest of the paper will try to convince you that while there is a limited class of problems for which threads are a good solution, your problem is almost certainly not among them -- no matter what your problem is.

  9. #9
    Registered User
    Join Date
    Aug 2003
    Posts
    470
    What Salem said seems more appropriate for a server. But if you want a gui client, then threads or processes are pretty much necessity. Your program could spend up to 10 seconds just waiting for the network connection to time out, and before it does time out your user won't be able to even close the application properly. Not good. Instead, I'd use threads, but I'd have to keep track of all the data structures and asynchronous messages the different threads use. At least in my case, the data is limited to two clases. Guarding this data is quite easy, and because each thread never has to lock two objects, dead lock cannot happen.
    Last edited by okinrus; 06-18-2005 at 09:40 AM.

  10. #10
    x4000 Ruski's Avatar
    Join Date
    Jun 2002
    Location
    Outer Space!
    Posts
    542
    Umm, yeah, probably select() will work for this one, cause It's not over internet and stuff, just a LAN connection and connecting won't probably timeout and stuff.. I actually wanted to make a multi user poker card game anywayz.. what's a dead lock? and how do you guard your data when dealing with threads?
    what does signature stand for?

  11. #11
    Registered User Codeplug's Avatar
    Join Date
    Mar 2003
    Posts
    4,676
    Here is a basic tutorial in multithreading in Windows:
    http://www.adrianxw.dk/SoftwareSite/.../Threads1.html

    And there's MSDN:
    Multithreading for Rookies
    Synchronization

    gg

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. overlapped I/O and multi threading
    By krishnampkkm in forum C++ Programming
    Replies: 2
    Last Post: 06-22-2009, 03:27 PM
  2. Multi Threading
    By beon in forum C Programming
    Replies: 5
    Last Post: 12-04-2006, 08:21 PM
  3. Replies: 6
    Last Post: 06-02-2006, 08:32 AM
  4. starting to learn multi threading
    By hanhao in forum C++ Programming
    Replies: 2
    Last Post: 06-09-2004, 01:44 PM
  5. Multi Threading
    By IceBall in forum C Programming
    Replies: 7
    Last Post: 07-13-2003, 03:01 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21