Threads are useful in many ways:
- In situations where several things must happen at once multi-threading
has great appeal. For example, a multimedia application can requre
audio, video, and control processes to run in parallel. Similarly,
there are often periods of waiting on slow IO systems to respond
when the processor could be doing other tasks..
- Some programs such as server/client systems are much easier
to design and write with threads.
- Some mathematical algorithms such as sorting, prime searching,
etc are suitable for parallel processing.
- On multiprocessor systems, the JVMs can put threads on different
processors and thus obtain true parallel processing and get significant
speedups in performance over single processor platforms.
In the following sections we will look at examples of programs
that use threads. We begin with a simple animation example. We then
look at cases with multiple threads and categorize them according
to the degree the threads interact with each other.
|