Thread vs Process

This is a discussion on Thread vs Process within the C++ Programming forums, part of the General Programming Boards category; Can anyone tell me what's the difference between Thread and Process ? IN what circumstance i should use Thread ? ...

  1. #1
    Registered User
    Join Date
    Jul 2007
    Posts
    10

    Thread vs Process

    Can anyone tell me what's the difference between Thread and Process ? IN what circumstance i should use Thread ? and in what circumstance i should use Thread ?

  2. #2
    Kiss the monkey. CodeMonkey's Avatar
    Join Date
    Sep 2001
    Posts
    902
    I was under the impression that a thread is a channel on which one runs processes, one at a time. I'm not sure as to the exact distinction. But now that I have just googled "process vs. thread," I know. (no sarcasm here: the first three results cover it.)

    *edit* and it turns out that I was at first thought wrong.
    "If you tell the truth, you don't have to remember anything"
    -Mark Twain

  3. #3
    Unregistered User Yarin's Avatar
    Join Date
    Jul 2007
    Posts
    1,605
    Just always use threads, and only use process when you have to. (ie, debugging, floating, ect...)

  4. #4
    Registered User
    Join Date
    Jul 2007
    Posts
    10
    Quote Originally Posted by Yarin View Post
    Just always use threads, and only use process when you have to. (ie, debugging, floating, ect...)


    Mind to elaborate ?

  5. #5
    Unregistered User Yarin's Avatar
    Join Date
    Jul 2007
    Posts
    1,605
    On what?

  6. #6
    Registered User
    Join Date
    Jun 2007
    Posts
    24
    Quote Originally Posted by Yarin View Post
    On what?
    I think cpp means the thing about threads and processes

  7. #7
    Deathray Engineer MacGyver's Avatar
    Join Date
    Mar 2007
    Posts
    3,211
    Quote Originally Posted by tbca View Post
    I think cpp means the thing about threads and processes
    And that means what?

    What is the matter with so many people being so vague?

    It's not like there's only one answer for every combination of questions having to do with processes and threads. The OP would do better to ask a specific question.

  8. #8
    Algorithm Dissector iMalc's Avatar
    Join Date
    Dec 2005
    Location
    New Zealand
    Posts
    6,299
    Quote Originally Posted by cppnewbie81 View Post
    Can anyone tell me what's the difference between Thread and Process ? IN what circumstance i should use Thread ? and in what circumstance i should use Thread ?
    Hmm, sounds like you really wanna use a thread!

    You use a thread when you need finer control over it such as the ability to pause and unpause it. Also you use a thread when it would need to share data with the rest of your threads. If it has nothing in common with your other threads, and in fact doesn't even need to know about them, and can run without them, then perhaps it could be a seperate process.
    My homepage
    Advice: Take only as directed - If symptoms persist, please see your debugger

    Linus Torvalds: "But it clearly is the only right way. The fact that everybody else does it some other way only means that they are wrong"

  9. #9
    Unregistered User Yarin's Avatar
    Join Date
    Jul 2007
    Posts
    1,605
    I thought I was being as clear as I can, sorry.

  10. #10
    Registered User Mortissus's Avatar
    Join Date
    Dec 2004
    Location
    Brazil, Porto Alegre
    Posts
    152
    I think that this is a whole subject, and should be studied in books or articles. Even the concept of thread is different between operational systems. I fear that here, in the forum, you won't get a complete answer in a few lines.

    If you just want to get the easy answer, I must add to the explanation given: threads are low overhead processes. This means that they are not exactly a process, they are lightweight processes. They have different characteristics, as explained by iMalc, like the capability to access to share the same memory area. Think in threads like slaves obeying to a master (the process).

  11. #11
    Captain - Lover of the C
    Join Date
    May 2005
    Posts
    341
    Here's my explanation:
    When you run a program on windows, you are starting a process. If you wrote the program then you wrote the process. Processes are made up of threads. A simple program will have one thread. So the funny thing is that your are using both a thread and a process at the same time. Now, within your process, you have the choice to start more threads. Your one process can be running several threads at one time and have control over them. They are all still linked to your process to if you close the process, you close the threads. The question you want an answer to is this:
    If I need multiple operations to run at the same time, should I write multiple programs or just make more threads within a single program? To answer than, it depends on how much the operations need to communicate and whether you really want to start writing a multithreaded application for something that could be done simply with two programs running at the same time.
    Don't quote me on that... ...seriously

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. create a child process that creates a child process
    By cus in forum Linux Programming
    Replies: 9
    Last Post: 01-13-2009, 01:14 PM
  2. Thread Prog in C language (seg fault)
    By kumars in forum C Programming
    Replies: 22
    Last Post: 10-09-2008, 01:17 PM
  3. API Thread HEADACHE
    By WaterNut in forum Windows Programming
    Replies: 11
    Last Post: 01-16-2007, 09:10 AM
  4. multithreading question
    By ichijoji in forum C++ Programming
    Replies: 7
    Last Post: 04-12-2005, 10:59 PM
  5. Win32 Thread Object Model Revisted
    By Codeplug in forum Windows Programming
    Replies: 5
    Last Post: 12-15-2004, 07:50 AM

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