General Thread question

This is a discussion on General Thread question within the Windows Programming forums, part of the Platform Specific Boards category; Is it important to know/use threads when doing Windows programs? Can you give a (real) example where it's useful, and ...

  1. #1
    Confused Magos's Avatar
    Join Date
    Sep 2001
    Location
    Sweden
    Posts
    3,145

    General Thread question

    Is it important to know/use threads when doing Windows programs?
    Can you give a (real) example where it's useful, and where you absolutely HAVE TO use it?
    MagosX.com

    Give a man a fish and you feed him for a day.
    Teach a man to fish and you feed him for a lifetime.

  2. #2
    Registered User
    Join Date
    Nov 2001
    Posts
    1,348
    Thread is imperative for Windows as well as program on all other operating systems. Without the use of threads, there is no way a process or processes could perform multiple tasks. Multithreading and multiprocessing are standards for multitasking and multiusers operating systems.

    For example, consider a Windows game such as the upcoming Unreal Tournament 2003. You cannot do calculations and update gamers graphically in real-time without using multithreading and multiprocessing.

    Kuphryn

  3. #3
    Confused Magos's Avatar
    Join Date
    Sep 2001
    Location
    Sweden
    Posts
    3,145
    If you do them one at a time, you get the illusion of them being done at the same time.
    Code:
    while(MainLoopIsOn)
    {
       GetPlayerInput();
       MovePlayers();
       MoveEnemies();
       UpdateScreen();
    }
    If I'm not mistaken, threads doesn't execute several codes "at the same time", it only runs parts from one code, then a little form the next etc...

    Anyway, it's not my intention to argue against you.
    Thanks for the reply!
    MagosX.com

    Give a man a fish and you feed him for a day.
    Teach a man to fish and you feed him for a lifetime.

  4. #4
    &TH of undefined behavior Fordy's Avatar
    Join Date
    Aug 2001
    Posts
    5,789
    Originally posted by Magos
    If you do them one at a time, you get the illusion of them being done at the same time.
    Code:
    while(MainLoopIsOn)
    {
       GetPlayerInput();
       MovePlayers();
       MoveEnemies();
       UpdateScreen();
    }
    Yeah...but assume each of these 4 functions tales up .25 seconds on a normal priority thread running in the system with all the other threads........now to complete this block, you have lost 1 second......if they were multithreaded you would get closer to .25 seconds....not bad if it works

    Originally posted by Magos

    If I'm not mistaken, threads doesn't execute several codes "at the same time", it only runs parts from one code, then a little form the next etc...
    Yeas but it does this very fast.....when you create anoter thread, you have 2 chances of execution instead of 1...therefore, to all reason, they are running at the same time (or very close)

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. General linking question
    By BrandonW in forum C Programming
    Replies: 5
    Last Post: 05-02-2007, 01:24 PM
  2. General question from a beginner to Windows C++ programming
    By Kontan in forum Windows Programming
    Replies: 1
    Last Post: 09-29-2006, 09:03 PM
  3. [code] Win32 Thread Object
    By Codeplug in forum Windows Programming
    Replies: 0
    Last Post: 06-03-2005, 04:55 PM
  4. 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
  5. general pointer & malloc question
    By jstn in forum C Programming
    Replies: 2
    Last Post: 05-14-2002, 10:51 AM

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