Java Multithreading
Java Multithreading
MutliThreading
www.btechsmartclass.com
Introduction
Every java application runs with the concept of threads or multithreading
In this process is the smallest unit. In this thread is the smallest unit.
Process never gain access over idle time of CPU. Thread gain access over idle time of CPU.
What is Parallelism?
It is the process of executing multiple processes simultaneously
on individual CPUs
Thread
Definition: A part of the program which can run individually
Thread
which is in the
java.lang
package
Use of
Thread
predefined class
What is Parallelism?
Creating
Thread
Create an object of Thread class
Thread t = new Thread( ) ;
Override run() method with the code to be run by that thread
public void run( ){
Code to be run by the
thread
…..
}
Call the run( ) method using start( ) method
t . Start( );