From 1d743aedb3ef68455c16544580f8e412f9c52756 Mon Sep 17 00:00:00 2001 From: Aadit Agrawal Date: Mon, 14 Oct 2024 09:29:32 +0530 Subject: [PATCH] Delete OOP/Java/Lab/syncMethod.java --- OOP/Java/Lab/syncMethod.java | 43 ------------------------------------ 1 file changed, 43 deletions(-) delete mode 100644 OOP/Java/Lab/syncMethod.java diff --git a/OOP/Java/Lab/syncMethod.java b/OOP/Java/Lab/syncMethod.java deleted file mode 100644 index 59a3419..0000000 --- a/OOP/Java/Lab/syncMethod.java +++ /dev/null @@ -1,43 +0,0 @@ - -class Incrementer{ - int count; - Incrementer(int cnt) - { - count=cnt; - } - synchronized void increment() - { - count++; - } -} - -class IncrementThread extends Thread{ - Incrementer ref; - IncrementThread(Incrementer obj) - { - ref=obj; - } - public void run() - { - for(int i=0;i<10000;i++) - { - ref.increment(); - } - } -} -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); - } -}