From 6b3472cf53c85971e69bb2edf345b40d72165cff Mon Sep 17 00:00:00 2001 From: Aadit Agrawal Date: Mon, 14 Oct 2024 09:29:40 +0530 Subject: [PATCH] Delete OOP/Java/Lab/syncStatements.java --- OOP/Java/Lab/syncStatements.java | 44 -------------------------------- 1 file changed, 44 deletions(-) delete mode 100644 OOP/Java/Lab/syncStatements.java diff --git a/OOP/Java/Lab/syncStatements.java b/OOP/Java/Lab/syncStatements.java deleted file mode 100644 index e557deb..0000000 --- a/OOP/Java/Lab/syncStatements.java +++ /dev/null @@ -1,44 +0,0 @@ -class IncrementThread extends Thread{ - Incrementer ref; - IncrementThread(Incrementer obj) - { - ref=obj; - } - public void run() - { - for(int i=0;i<10000;i++) - { - ref.increment(); - } - } -} -class Incrementer{ - int count; - Incrementer(int cnt) - { - count=cnt; - } - void increment() - { - synchronized(this) - { - count++; - } - } -} -class syncMethod{ - public static void main(String[] args) { - Incrementer inc=new Incrementer(0); - IncrementThread t1=new IncrementThread(inc); - IncrementThread t2=new IncrementThread(inc); - t1.start(); - t2.start(); - try { - t1.join(); - t2.join(); - } catch (InterruptedException e) { - System.out.println(e.toString()); - } - System.out.println(inc.count); - } -}