5 - Multithreading
5 - Multithreading
DEVELOPMENT-1
Tharanga Ekanayake
BSc (Special) MIS, First Class
Multithreading
• A thread is a light-weight smallest part of a process that can run concurrently with the other
parts(other threads) of the same process.
• Multithreading in Java is a process of executing multiple threads simultaneously.
• We use multithreading than multiprocessing because threads use a shared memory area.
Main Thread
start
start start
driverClass
class NameRunnable extends Thread
{
public void run()
{
for (int x = 1; x < 11; x++) {
System.out.println(""+Thread.currentThread().getName() +" : "+x);
}
}
}
public class one {
public static void main (String [] args) {
NameRunnable nr = new NameRunnable();