lab3/src/main/java/com/mycompany/lab3/Barrier.java
/**
     * Threads are forced to go through arrival method in stages,
     * first stage increment count till all threads arrive(using s_lock1)
     * second stage decrement count till all threads arrive(using s_lock2)
     */
Threads are forced to go through arrival method in stages,
first stage increment count till all threads arrive(using s_lock1)
second stage decrement count till all threads arrive(using s_lock2)
Threads are forced to go through arrival method in stages first stage increment count till all threads arrive ( using s_lock1 ) second stage decrement count till all threads arrive ( using s_lock2 )
public void arrival(){
        try {
            mutex.acquire();
            count++;
            if(count==total){
                s_lock1.release(total);
            }
            mutex.release();
            s_lock1.acquire();
            mutex.acquire();
            count--;
            if(count == 0){
                s_lock2.release(total);
            }
            mutex.release();
            s_lock2.acquire();
        } catch (Exception e) {
            System.out.println(e.getLocalizedMessage());
        }
    }
public void arrival ( ) { try { mutex . acquire ( ) ; count ++ ; if ( count == total ) { s_lock1 . release ( total ) ; } mutex . release ( ) ; s_lock1 . acquire ( ) ; mutex . acquire ( ) ; count -- ; if ( count == 0 ) { s_lock2 . release ( total ) ; } mutex . release ( ) ; s_lock2 . acquire ( ) ; } catch ( Exception e ) { System . out . println ( e . getLocalizedMessage ( ) ) ; } }
Threads are forced to go through arrival method in stages,
 first stage increment count till all threads arrive(using s_lock1)
 second stage decrement count till all threads arrive(using s_lock2)
Threads are forced to go through arrival method in stages first stage increment count till all threads arrive ( using s_lock1 ) second stage decrement count till all threads arrive ( using s_lock2 )