Chris,
I will attempt to answer the question. I am sure that if I have any
facts wrong I will be corrected. :-)
Threads are basically separate processes running reasonably
independently of each other. Sometimes they share memory but often they
run in their own "space". Think of them as a a program that runs next to
the parent program.
Threads are often useful for when there is a side job to do that will
take a while to run but you want to continue with the main program eg
give back control to the user.
The main problem with threads is that once you've set them going you
need a way for the thread to tell the main process what's going on i.e.
when the thread has finished it's job.
There is usually no way of predicting exactly when the thread will be
finished so you need to do things like the event based message loops of
GUIs that look for messages sent from the thread.
If you have more than one thread running then things can get pretty
hairy hence the comments on non-determinism (determinism==predictability).
That's a pretty simplistic view of threads but I HTH.
Regards,
Zane
TH & CD Maher wrote:
I haven't had too much to do with threads, except with Java in Wind0wz and C++
in Wind0wz and in my experience they are a very useful programming tool. Can
anyone simply and concisely explain to me how they work and why they're used.
Are threads only used in OO programming?
Reagrds,
Chris Maher.