From 1e1194882a3e8021affdcca2a6f35a3c4a63faa4 Mon Sep 17 00:00:00 2001 From: nagesh srinivas Date: Sun, 15 Mar 2020 23:59:12 +0530 Subject: [PATCH 1/3] Create semaphore.java --- semaphore.java | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 semaphore.java diff --git a/semaphore.java b/semaphore.java new file mode 100644 index 0000000..2035185 --- /dev/null +++ b/semaphore.java @@ -0,0 +1,21 @@ +public class Semaphore { + private int signals = 0; + private int bound = 0; + + Semaphore(int upperBound){ + this.bound = upperBound; + } + + public synchronized void take() throws InterruptedException { + while(this.signals == bound) wait(); + this.signals++; + this.notify(); + } + + public synchronized void release() throws InterruptedException{ + while(this.signals == 0) wait(); + this.signals--; + this.notify(); + } + +} From cb45a12634904a38c4eec1c8e1d9548406710042 Mon Sep 17 00:00:00 2001 From: last-saiyan <50881789+last-saiyan@users.noreply.github.com> Date: Thu, 9 Apr 2020 02:10:59 +0530 Subject: [PATCH 2/3] Create CyclicBarrier.java --- CyclicBarrier.java | 1 + 1 file changed, 1 insertion(+) create mode 100644 CyclicBarrier.java diff --git a/CyclicBarrier.java b/CyclicBarrier.java new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/CyclicBarrier.java @@ -0,0 +1 @@ + From 8718877db9872ba4b0bf4ae22197ef4ac35deb4b Mon Sep 17 00:00:00 2001 From: last-saiyan <50881789+last-saiyan@users.noreply.github.com> Date: Thu, 9 Apr 2020 02:11:50 +0530 Subject: [PATCH 3/3] Create CountdownLatch.java --- CountdownLatch.java | 1 + 1 file changed, 1 insertion(+) create mode 100644 CountdownLatch.java diff --git a/CountdownLatch.java b/CountdownLatch.java new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/CountdownLatch.java @@ -0,0 +1 @@ +