@Override
    public void run() 
    {
       synchronized (numberOfActiveProducersLock) {
			numberOfActiveProducers++;
		}
        Random r =new Random();
        try{
                for(int i=0 ; i<maxItemsToProduce ; i++)
                {
                    if(sharedQueue.isFull()){
                        break; //stop producing when queue is full
                    }

                             int producedItem=r.nextInt(45);
                             System.out.println("producer['" + name + "'] >>> producing '" + producedItem + "' (producedCount: " + i + ")");

                             sharedQueue.addItem(producedItem);

                             Thread.sleep(r.nextInt(50));
                }
            } catch (InterruptedException ex) {}
               
        synchronized (numberOfActiveProducersLock) {
			numberOfActiveProducers--;
		}
            }