Multitasking:
Executing several task simultaneously is called multitasking
Process-based multitasking:- Executing several task simultaneously where each task is a separate independent process such type of multitasking is called process based Multitasking.
Example:-While typing a program in the editor we can listen MP3 audio songs. At the same time we download a file from the net. all these task are executing simultaneously and each task is a separate independent program. hence it is process based multitasking. It is best suitable at operating system level.
Thread-based multitasking:- Executing several task simultaneously where each task is a separate independent part of the same program is called Thread-based multitasking. and every independent part is called a thread. This type of multitasking is best suitable at programmatic level.
Multithreading:
Executing several thread simultaneously where each thread is a separate independent part of the same program is called multithreading. Java language provides inbuilt support for multithreading by defining a rich library, classes and interfaces like Thread, ThreadGroup, Runnable etc.
Examples:The main important application area of multithreading are video games implementation, animation development, multimedia graphics etc.
Advantage of Multithreading:
The main advantage of multithreading is reduces response time and improves performance of the system
When compared with C++ what is the advantage in java with respect to Multithreading :
Java language provides inbuilt support for multithreading by defining a reach library, classes and interfaces like Thread, ThreadGroup, Runnable etc. But in c++ there is no inbuilt support for multithreading
How Many ways we can define a Thread
We can define a Thread in the following two ways:
1. by
extending Thread class or
2. by
implementing Runnable interface.
Among the two ways of
defining a thread implementing Runnable mechanism is always recommended. In the
first approach as our Thread class already extending Thread there is no chance
of extending any other. Hence, we missing the key benefit of oops(inheritance
properties).
Comments
Post a Comment