Pages

Showing posts with label Multhreading in Java. Show all posts
Showing posts with label Multhreading in Java. Show all posts

Wednesday, May 13, 2020

Multithreading in Java

Index:

  1. What is Thread?
  2. Advantages of thread?
  3. How Threads are created in java?  
  4. Difference between Thread class & Runnable interface?
  5. Lifecycle of thread (How thread travels) 


1. What is Thread?


1. Any executable program is called as Thread.

2. Thread is a class in java present in java.lang package

3. Process of executing multiple threads simultaneously is called as MultiThreading.

Consider below example to understanding thread:

MultiProcessing Vs MultiThreading
Example of Multithreading
In above figure, Thread-1 and Thread-2 are executing at a time so it's called as Multithreading.