package be.ac.vub.ir.multithreading; /** * Another version, with consumers that are also producers */ import java.util.Random; import java.util.concurrent.locks.Condition; import java.util.concurrent.locks.ReentrantLock; public class ApplesOrangesWithDeadlock { static final int MAX_SLEEP_TIME = 100; static int NBR_APPLE_PRODUCERS = 2, NBR_ORANGE_PRODUCERS=2; private int nbrApples=5, nbrOranges=5, consumedApples=0, consumedOranges=0; boolean stop=false; private final ReentrantLock lock = new ReentrantLock(); private final Condition noApples = lock.newCondition(); private final Condition noOranges = lock.newCondition(); /**** PROGRAM ***/ public static void main(String[] args) { new ApplesOrangesWithDeadlock(); } ApplesOrangesWithDeadlock(){ start(); } public void start(){ System.out.println(" nbrApples nbrOranges consumedApples consumedOranges"); for(int i=0;i