diff --git a/staticSynchronization.java b/staticSynchronization.java new file mode 100644 index 000000000000..2b22b78093c7 --- /dev/null +++ b/staticSynchronization.java @@ -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(); + } +}