program TurnstileMain { // checking the number of arguments if (args.length==0) { System.out.println("The number of turnstiles is missing"); System.exit(1); } // if Turnstile turnstiles[] = null; try { turnstiles= new Turnstile[Integer.parseInt(args[0])]; } catch(NumberFormatException e) { e.printStackTrace(); System.exit(2); } // try Counter c = new Counter(); semaphore mutex(1); cobegin { for (int i=0;i< turnstiles.length;i++) { turnstiles[i]= new Turnstile(c,mutex); } // for } // cobegin System.out.printf("counter value: %d\n",c.getValue()); } // program