Code example for Semaphore

0
     * @param args command line arguments 
     */ 
    public static void main(final String[] args) {
 
        // semaphore control the access to the 3 available cash machines 
        Semaphore cashmachines = new Semaphore(2);
 
        new Thread(new Person(cashmachines, "Einstein"), "Einstein").start();
        new Thread(new Person(cashmachines, "Fermi"), "Fermi").start();
        new Thread(new Person(cashmachines, "oppenheimer"), "oppenheimer").start();
        new Thread(new Person(cashmachines, "Majorana"), "Majorana").start();
        new Thread(new Person(cashmachines, "Turing"), "Turing").start();
        new Thread(new Person(cashmachines, "von Neumann"), "von Neumann").start();
    } 
}