@Override
	public void run() {

		synchronized (numberOfActiveProducersLock) {
			numberOfActiveProducers++;
		}

		Random rnd = new Random();

		try {

			for (int i=1; i<=maxItemsToProduce; i++) {

				if (warehouse.isFull()) {
					break; //stop producing when warehouse is full
				}

				int producedItem = rnd.nextInt(100);
				System.out.println("producer['" + name + "'] >>> producing '" + producedItem + "' (producedCount: " + i + ")");
	
				warehouse.addItem(producedItem);
	
				Thread.sleep(rnd.nextInt(50));
			}

		} catch (InterruptedException ex) {
			System.out.println("Producer '" + name + "' process killed");
		}

		synchronized (numberOfActiveProducersLock) {
			numberOfActiveProducers--;
		}
	}