Changes as per review comments

This commit is contained in:
RanjeetKaur17 2018-10-24 23:05:27 +04:00
parent e5f43622be
commit a559137c8c
3 changed files with 8 additions and 7 deletions

View File

@ -23,10 +23,11 @@ public class CountdownLatchResetExample {
ExecutorService es = Executors.newFixedThreadPool(threadCount);
for (int i = 0; i < threadCount; i++) {
es.execute(() -> {
if (countDownLatch.getCount() > 0) {
outputScraper.add("Count Left : " + countDownLatch.getCount());
}
long prevValue = countDownLatch.getCount();
countDownLatch.countDown();
if (countDownLatch.getCount() != prevValue) {
outputScraper.add("Count Updated");
}
});
}

View File

@ -26,7 +26,7 @@ public class CyclicBarrierCountExample {
}
public static void main(String[] args) {
CyclicBarrierCountExample ex = new CyclicBarrierCountExample(1);
CyclicBarrierCountExample ex = new CyclicBarrierCountExample(7);
System.out.println("Count : " + ex.callTwiceInSameThread());
}
}

View File

@ -28,7 +28,7 @@ public class CyclicBarrierResetExample {
es.execute(() -> {
try {
if (cyclicBarrier.getNumberWaiting() > 0) {
outputScraper.add("Waiting Count : " + cyclicBarrier.getNumberWaiting());
outputScraper.add("Count Updated");
}
cyclicBarrier.await();
} catch (InterruptedException | BrokenBarrierException e) {
@ -41,7 +41,7 @@ public class CyclicBarrierResetExample {
}
public static void main(String[] args) {
CyclicBarrierResetExample ex = new CyclicBarrierResetExample(new ArrayList<String>(), 5, 20);
CyclicBarrierResetExample ex = new CyclicBarrierResetExample(new ArrayList<String>(), 7, 20);
System.out.println("Count : " + ex.countWaits());
}
}