public class Storage 
{
  private int value;
  

  public Storage(int v)
	{
		value = v;
	}
	
	public int getValue() 
	{ 
    	return value; 
	} 
  
  
    synchronized void take() 
    {
    	while(value <= 0) 
    	{
      		try 
      		{
        		wait();
      		} 
      		catch(InterruptedException e) 
      		{
        		System.out.println(e);
      		}
    	}
    	value--;
    	notifyAll();
  	}

  	synchronized void release() 
  	{
  		while(value > 8) 
    	{
      		try 
      		{
        		wait();
      		} 
      		catch(InterruptedException e) 
      		{
        		System.out.println(e);
      		}
    	}
    	value = value+2;
    	notifyAll();
    	   
   	}
}




