There are generally two kinds of multitasking operating systems: Multitasking is necessary in today's operating systems for better performance by making full use and optimize the usage of the computing resources. In a multi-CPU machine, a few tasks can be executed simultaneously, either distributed among or time-slicing the CPUs. In a single-CPU machine, only one task can be executed at one time – through time-slicing of the CPU. A multitasking system can perform many tasks concurrently by sharing the computing resources, such as CPU(s), main memory, and I/O channels. Modern operating systems (such as Windows and UNIX) are multitasking system. The following figure shows a program with 3 threads running under a single CPU: Multitasking (or Multi-processing) A thread by itself is not a program because it cannot run on its own. During the lifetime of the thread, there is only a single point of execution. A thread, also called a lightweight process, is a single sequential flow of programming operations, with a definite beginning and an end. Java has built-in support for concurrent programming by running multiple threads concurrently within a single program. The term " concurrency" refers to doing multiple tasks at the same time. A multi-thread program has an initial entry point (the main() method), followed by many entry and exit points, which are run concurrently with the main(). A single-thread program has a single entry point (the main() method) and a single exit point. Java supports single-thread as well as multi-thread operations.
0 Comments
Leave a Reply. |