class WalkmanHire {
    /*
        The Museum Walkman Hire Program from 'Java Gently' by JM Bishop
        simulates the hiring of Walkmen from a fixed pool for $1 each
        There are several helpers at different counters
        handling the hire and replacement of the Walkmen.
        
        The number of Walkmen in the original pool is 50
        and the number of helpers serving is 3. but these can be
        overridden by parameters at runtime
        eg java WalkmanHire 100 8
        
        Illustrates monitors with sycnchronize, wait and notify.
        Shows a main program and two different kinds of threads
        running simultaneously.
    */

    static int pool;
    static int helpers;
    
    public static void main(String[] args) {
        
        // Get the number of Walkmen in the pool 
        // and open the museum for business
        if(args.length >= 1)
            pool = Integer.parseInt(args[0]);
        else
            pool = 50;
        Museum m = new Museum(pool);
        
        // Get the number of helpers
        // and open the counters
        if(args.length >= 2)
            helpers = Integer.parseInt(args[1]);
        else
            helpers = 3;
            
        for(int i=0; i<helpers; i++)
            new Counter(m, i).start();
        
    }
}