We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent dfd8d69 commit 496d935Copy full SHA for 496d935
staticSynchronization.java
@@ -0,0 +1,38 @@
1
+class Table{
2
+
3
+ synchronized static void printTable(int n){
4
5
+ for (int i = 1; i <=3; i++){
6
7
+ System.out.println(n * i);
8
+ try {
9
+ } catch (Exception e) {
10
+ System.out.println(e);
11
+ }
12
13
14
+}
15
16
+class Thread1 extends Thread{
17
18
+ public void run() {
19
+ Table.printTable(1);
20
21
22
23
+class Thread2 extends Thread {
24
25
+ Table.printTable(10);
26
27
28
29
+public class staticSynchronization {
30
31
+ public static void main(String[] args){
32
33
+ Thread1 t1 = new Thread1();
34
+ Thread2 t2 = new Thread2();
35
+ t1.start();
36
+ t2.start();
37
38
0 commit comments