Fred Exley wrote:
Just trying to understand the basics here. If the OS has just one CPU,
what
advantage is there in threading? thanks
Hi Fred,
Threading is everywhere. It's not just a concept that's useful on two CPUs.
Take two applications, AppA and AppB. If you start these on your computer,
how can you switch between them? How can AppA calculate a list of prime
numbers, while AppB is calculating Pi to a million decimal places?
The answer is threading: Whenever you start a process, that process will
initially begin in one thread, and can then spawn more and more threads.
Going back to AppA and AppB, when you launch these two applications, AppA
will start it's thread and AppB will start it's thread. AppA's thread
contains code to calculate prime numbers and AppB's thread contains code to
calculate Pi. These two processes appear to run simultaneously, because
the operating system is scheduling the execution of each thread, and
allowing the thread to run.
Taking a much larger example, e.g. Microsoft Word, and Microsoft Visual
Studio. When you launch these applications, you can switch between them,
you can start VS compiling and you can write a document in Word. These
applications also create multiple threads, to do various tasks.
Multiple threads within a single process are used to execute code
simultaneously (or what appears to be simultaneously).
The following article will probably be of better use to you:
http://en.wikipedia.org/wiki/Thread_...ter_science%29
--
Hope this helps,
Tom Spink