class Shared {    static int count = 0;} class Threads extends Thread {    Semaphore s;    String baboon;        public Threads(Semaphore s, String baboon) {        super(baboon);        this.s = s;        this.baboon = baboon;    } @Overridepublic void run() {    if(this.getName().equals(“eastward-moving baboon”)) {                System.out.println(baboon + ” Heading to bridge”);        try {            System.out.println(baboon + ” sleeping at the bridge”);            s.acquire();                    System.out.println(baboon + ” wake up”);                     for(int i=0; i < 3; i++) {                            Shared.count++;                System.out.println(baboon + ": " + Shared.count);                         Thread.sleep(10);            }         }             catch (Exception e) {                System.out.println(e);            }                System.out.println(baboon + " finished crossing the bridge");                s.release();        }        else {        System.out.println(baboon + " Heading to the bridge");        try {            System.out.println(baboon + " sleeping at the bridge");            s.acquire();                         System.out.println(baboon + " wake up");            for(int i=0; i < 3; i++) {                Shared.count++;                System.out.println(baboon + ": " + Shared.count);                                    Thread.sleep(10);                }            }             catch (Exception e) {                    System.out.println(e);                }                System.out.println(baboon + " finished crossing");                s.release();        }    }}public class question8 {    public static void main(String args) throws Exception {         Semaphore s1 = new Semaphore(1);        Threads t1 = new Threads(s1, "eastward-moving baboon");        Thread t2 = new Threads(s1, "westward-moving baboons");                t1.start();        t2.start();        t1.join();        t2.join();         System.out.println(" Done!");    }}