예제 #1
0
	synchronized void enterLaneB(Car car) throws InterruptedException {
		while (currentWeightA + currentWeightB + car.getWeight() >= maximumWeight || Math.abs(currentWeightA - currentWeightB + car.getWeight()) >= maximumDifference) {
			wait();
		}
		currentWeightB += car.getWeight();
		notifyAll();
	}
예제 #2
0
	synchronized void exitLaneB(Car car) throws InterruptedException {
		while (Math.abs(currentWeightA - currentWeightB) >= maximumDifference) {
			wait();
		}
		currentWeightB -= car.getWeight();
		notifyAll();
	}