Az Oop 8 PDF
Az Oop 8 PDF
URK23CO2018
Date of Exercise
Aim
To use the concepts of Multithreading by extending the Thread class for the given problems using
Java language.
Description
Java multithreading allows multiple threads to run concurrently, making it possible to execute
multiple tasks simultaneously within a single program. It can improve the performance of
applications
Multithreading Syntax:
Creating a thread:
System.out.println("Thread is running...");
}}
thread.start(); } }
1
23DC2002 - Object Oriented Programming Lab Reg.No. URK23CO2018
1. Write a program that create a thread and display the line of multiplication table of
number 5 for every 3 seconds.
Program
2
23DC2002 - Object Oriented Programming Lab Reg.No. URK23CO2018
2. Create a java application that uses multi-threading concept to perform the following.
4. Perform Sum of numbers using the thread name called “t4” Program
import java.util.Scanner;
public InputThread() {
super("t1");
}
3
23DC2002 - Object Oriented Programming Lab Reg.No. URK23CO2018
4
23DC2002 - Object Oriented Programming Lab Reg.No. URK23CO2018
sum += i;
}
System.out.println("Sum of numbers between " + num1 + " and " + num2 + " by " +
Thread.currentThread().getName() + ": " + sum);
}
}
t2.start();
t3.start();
t4.start();
t2.join();
t3.join();
t4.join();}
}
Output Screenshot
Result