Multithreading in Java and

In this article, we are going to discuss Multithreading in Java and types. 

  • What is the thread
  • Multitasking
  • Process-based Multitasking (Multiprocessing)
  • Thread-based Multitasking (Multithreading)

 

Multithreading in Java

Introduction

In java, Multithreading means multiple threads executing simultaneously in a process is called Multithreading.

By definition, multitasking is when multiple processes share common processing resources such as a CPU.

 

What is the thread?

A thread is a sub-process of a process. When a big process is divided into multiple small processes, then that small process is called a thread.

 

Multitasking

Executing multiple tasks simultaneously is called Multitasking. We use multitasking to utilize the CPU.

There are two types of multitasking.

  1. Process-based Multitasking
  2. Thread-based Multitasking

 

Process-based Multitasking (Multiprocessing)

Executing multiple tasks simultaneously, where each task is a separate independent process is called Process-based multitasking.

Each process has an address in memory. In other words, each process allocates a separate memory area.

Example:

While a user typing a java programming in the editor, he can able to listing audio songs by an MP3 player in the system, and at the same time, he can also downloading movies file from the internet. So all these tasks are executing simultaneously and independently of each other.n That why this process is called Process-based Multitasking.

Process-based Multitasking is best suitable at the O.S level.

 

Thread-based Multitasking (Multithreading)

Executing multiple tasks simultaneously, where each task is a separate independent part of the same program is called Thread-based Multitasking.

Thread-based Multitasking is the best suitable for the programming level.

The main objective of Multitasking is to improve the performance of the system by reducing response time.

 

Read More topics related to the collection.

 

Read more topics related to java

 

Hope this was helpful for you. If you have any questions please feel free to leave a comment. Thank you for reading.

 

Leave a Reply

Your email address will not be published. Required fields are marked *