Before going to know about multi threading, we need to know about multi tasking.
What is Multitasking?
Executing several tasks simultaneously is called multitasking.
We have following types of multi tasking.
1. Process-based multitasking
2. Thread-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 Internet.
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.
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.
Example:-While typing a some notes in word document it can check for grammer and spelling.
I hope now we got some information about threads. So now we need to know What is 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 like Thread, ThreadGroup and interfaces like Runnable etc. Other OOPs languages like c++ does not have built in support for multithreading.
What is Multitasking?
Executing several tasks simultaneously is called multitasking.
We have following types of multi tasking.
1. Process-based multitasking
2. Thread-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 Internet.
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.
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.
Example:-While typing a some notes in word document it can check for grammer and spelling.
I hope now we got some information about threads. So now we need to know What is 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 like Thread, ThreadGroup and interfaces like Runnable etc. Other OOPs languages like c++ does not have built in support for multithreading.
The main advantage of multithreading is reduces response time and improves performance of the system.
We can define the thread in following ways:
- By extending Thread class or
- By implementing Runnable interface.
Among the two ways of defining a thread implementing Runnable mechanism is always recommended because in 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).
No comments:
Post a Comment