/**
   The Simulator creates a specified number of readers and writers and starts them.
  
   @author      Franck van Breugel
   @version     1.1    February 28, 2000
*/
public class Simulator 
{
    /** 
       Creates the specified number of readers and writers and starts them. 

       @param args[0] The number of readers.
       @param args[1] The number of writers.
    */
    public static void main(String[] args) 
    {
	if (args.length < 2)
	{
	    System.out.println("Usage: java Simulator <number of readers> <number of writers>");
	}
	else
	{
	    int readers = Integer.parseInt(args[0]);
	    int writers = Integer.parseInt(args[1]);
	    Monitor monitor = new Monitor();
	    for (int i = 1; i <= readers; i++) 
	    {
		new Reader(monitor).start();
	    }
	    for (int i = 1; i <= writers; i++) 
	    {
		new Writer(monitor).start();
	    }
	}
    }
}
