concurrency-problems

git clone git://git.codymlewis.com/concurrency-problems.git
Log | Files | Refs | README

commit 1860bf75f28940d0154a278ea691681e1ce8ce38
parent 9c5e5c310dc50c8fb7571f91f1a6bebf803a0750
Author: Cody Lewis <cody@codymlewis.com>
Date:   Fri,  4 Oct 2019 11:05:29 +1000

Added epsilon to problem B

Diffstat:
MCustomer.java | 4++--
MTimer.java | 1+
2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/Customer.java b/Customer.java @@ -70,9 +70,9 @@ public class Customer extends Thread implements Comparable<Customer> { */ public void run() { try { - Thread.sleep(arrivalTime * Timer.QUANTUM); + Thread.sleep(arrivalTime * Timer.QUANTUM + Timer.EPSILON); arrive(); - Thread.sleep(eatingTime * Timer.QUANTUM); + Thread.sleep(eatingTime * Timer.QUANTUM + Timer.EPSILON); this.stats += leave(); } catch (Exception e) { System.out.format("Error: %s", e.getMessage()); diff --git a/Timer.java b/Timer.java @@ -12,6 +12,7 @@ public class Timer extends Thread { * Amount of time (ms) for a single unit of sleep */ public static final int QUANTUM = 100; + public static final int EPSILON = 5; /** * Default constructor