/Multi-Threading

Multithreading is a Java feature that allows concurrent execution of two or more parts of a program for maximum utilization of CPU. Each part of such program is called a thread. So, threads are light-weight processes within a process.

Primary LanguageJava

Multi-Threading 🔄️

Unlike many other programming languages, Java provides built-in support for multithreaded programming. Multithreaded programming contains two or more parts that can run concurrently. Each piece of such a program is called a thread, and each thread defines a separate path of execution. Thus multithreading can be said as a particular version of multitasking.

What is Multithreading ?

The process of executing multiple tasks (also called threads) simultaneously is called multithreading. The primary purpose of multithreading is to provide simultaneous execution of two or more parts of a program to make maximum use of CPU time. A multithreaded program contains two or more parts that can run concurrently. It enables programmers to write in a way where multiple activities can proceed simultaneously within a single application.

What is Multitasking ?

It is the way of executing multiple tasks at a time executing them concurrently over a specified period. Multitasking is done in two ways.

These are:-

1️⃣ Process-based multitasking: It is also called multiprocessing where each process has its address in memory, i.e., each process allocates separate memory area.
2️⃣ Thread-based multitasking: This thread-based multitasking is also termed as multithreading where threads share the same address spac.

Life Cycle of a Thread 🧬

A thread goes through various stages of its life cycle. Example, first of all, a thread is born, started its tasks, run a sequence of tasks concurrently, and then dies. Here is the diagram of the various stages of a life cycle.

📬 Contact

If you want to contact me, you can reach me through below handles.

linkedinmail-mewhatsapp-mewhatsapp-me