The document contains Java code that defines three classes extending the Thread class, each responsible for printing the multiplication table of a given integer. The main class reads three integers from user input and starts three threads to execute the multiplication tables concurrently. Each thread prints the results from 1 to 10 for its respective integer.
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0 ratings0% found this document useful (0 votes)
3 views2 pages
Exp1 Ajava
The document contains Java code that defines three classes extending the Thread class, each responsible for printing the multiplication table of a given integer. The main class reads three integers from user input and starts three threads to execute the multiplication tables concurrently. Each thread prints the results from 1 to 10 for its respective integer.
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2
Experiment - 1
Code: import java.util.Scanner;
class a1 extends Thread {
int i1; a1(int i) { i1 = i; }
public void run() {
for (int b = 1; b <= 10; b++) { System.out.println(i1 + "x" + b + "=" + (b * i1)); } System.out.println("\n"); } }
class a2 extends Thread {
int j1; a2(int j) { j1 = j; }
public void run() {
for (int c = 1; c <= 10; c++) { System.out.println(j1 + "x" + c + "=" + (c * j1)); } System.out.println("\n"); } }
class a3 extends Thread {
int k1; a3(int k) { k1 = k; }
public void run() {
for (int d = 1; d <= 10; d++) { System.out.println(k1 + "x" + d + "=" + (d * k1)); } System.out.println("\n"); } }
class exp1_ajava { public static void main(String args[]) { Scanner sc = new Scanner(System.in); int i = sc.nextInt(); int j = sc.nextInt(); int k = sc.nextInt();
a1 ob1 = new a1(i);
ob1.start(); a2 ob2 = new a2(j); ob2.start(); a3 ob3 = new a3(k); ob3.start(); } }