-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBp6.java
More file actions
41 lines (33 loc) · 755 Bytes
/
Copy pathBp6.java
File metadata and controls
41 lines (33 loc) · 755 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
class Sync {
synchronized static void displayTable(int num) {
try {
for (int i = 1; i <= 10; i++) {
System.out.println(num + "*" + i + "=" + num * i);
Thread.sleep(1000);
}
} catch (Exception e) {
System.out.println(e);
}
}
}
class Mult extends Thread {
int n;
Mult(int n) {
this.n = n;
}
public void run() {
try {
Sync.displayTable(n);
} catch (Exception e) {
System.out.println("Error");
}
}
}
public class Bp6 {
public static void main(String arges[]) {
Mult m1 = new Mult(8);
Mult m2 = new Mult(9);
m1.start();
m2.start();
}
}