![]() |
![]() |
Introduction of Errors | |
Java Exceptions | |
Java Try Block | |
Java Catch Block | |
Java Finally Block | |
Java Throw Keyword | |
Java Throws Keyword | |
Java Builtin Exceptions | |
User Defined Exceptions |
Java Multithreading | |
Creating a Thread | |
Thread Life Cycle | |
Thread Exceptions | |
Thread Synchronization |
Java Programs | |
Java Keywords Dictionary | |
Java Interview Questions |
Java multithreading is a form of multitasking. A multithreaded program contains two or more parts that can run concurrently.
Each part of the program is called as a thread and each thread defines a seperate path of execution.
Program is divides into several subtasks for performing their operation at a time.
Example: While working on a computer you can perform many tasks at a time like typing a letter with listening a online song.
Process : It is program under the execution. Process based have following properties
Thread: It is smallest part of program for performing multitasking. Thread based have following properties
Sr.no | Multithreading | Multiprocessing |
---|---|---|
1. | Multi-threading refers to an application with multiple threads running within a process. | Multi-processing refers to an application organised across multiple OS-level processess. |
2. | Multi-threading means executing different parts of a program simultaneusly. | Multi-processing means executing several programs at a time using more than one processor. |
3. | Same job can be broken logically and executed simultaneously and the results are combined at the end of processing. | Several jobs can run at the same time. |
4. | The OS can allow hundreds of threads to be active, regardless of the number of processors. | Multiprocessing means that we are using a computer that has multiple processors. |
5. | Multithreading is the ability to perform different tasks of a process simultaneusly. | Multiprocessing have more than one processor. |
6. | Multithreading is achieved by using a separate thread for each task | Multiprocessing is achieved by hadling each thread to each separate processor. |
7. | From several threads in a process, at a time cpu will handle only a single thread. | It has concurrent processing system for performing all tasks at a time. |
8. | Multithreading is performed by switching between the tasks but,Not all at a time. | Multiprocessing is performed by simultaneusly performing tasks without switching between processess. |
9. | Program is divided into different parts(threads) which shares the memory and processor time and will be executed simultanuesly. | Processor allocates some memory for each program to be executed.Hence it has its own memory. |