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 ?
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 ?
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
Just always use threads, and only use process when you have to. (ie, debugging, floating, ect...)
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"
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).
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