Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions staticSynchronization.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
class Table{

synchronized static void printTable(int n){

for (int i = 1; i <=3; i++){

System.out.println(n * i);
try {
} catch (Exception e) {
System.out.println(e);
}
}
}
}

class Thread1 extends Thread{

public void run() {
Table.printTable(1);
}
}

class Thread2 extends Thread {
public void run() {
Table.printTable(10);
}
}

public class staticSynchronization {

public static void main(String[] args){

Thread1 t1 = new Thread1();
Thread2 t2 = new Thread2();
t1.start();
t2.start();
}
}
Loading