Help to transform int to bool conditions
<p>I have realized some logic using integers</p>

<pre><code>import java.util.concurrent.locks.*;

public class MassageSalon implements Salon{

    //I want to transform this into bool
    private int customerOnCouch = 0;
    private int customerPaid = 0;
    private int masseurAvailable = 0;
    private int masseurBusy = 0;
    private int masseurDone = 0;
    private int masseurClose = 0;

    Lock lock = new ReentrantLock();
    Condition sleep = lock.newCondition();

    public void getNextCustomer() throws InterruptedException{

        lock.lock();

        masseurAvailable++;

        System.out.println("masseur is available to handle a new customer");

        sleep.signalAll();

        //wait for next customer
        while(customerOnCouch &lt; masseurAvailable){

            System.out.println("masseur sleeps");

            sleep.await();

            System.out.println("masseur wakes up");
        }

        //customer takes couch, masseur busy
        masseurBusy++;

        System.out.println("masseur busy");

        lock.unlock();
    }

    public void finishedMassage() throws InterruptedException{

        lock.lock();

        //eventually the masseur finishes the massage

        System.out.println("eventually the masseur finishes the massage");

        masseurDone++;

        sleep.signalAll();

        //and closes the deal as soon as the customer paid
        while(masseurDone &gt; customerPaid){
            System.out.println("wait for payment");
            sleep.await();
        }

        System.out.println("and closes the deal as soon as the customer paid");

        masseurClose++;

        lock.unlock();
    }

    public void getMassage(int customerId) throws InterruptedException{

        lock.lock();

        while(customerOnCouch  &gt; masseurClose){
            System.out.println(customerId + " on couch waiting");
            sleep.await();
        }

        //takes couch
        customerOnCouch++;

        System.out.println(customerId + " on couch");

        sleep.signalAll();

        while(masseurDone &lt;= customerPaid){
            System.out.println("customer " + customerId + " sleeps");
            sleep.await();
        }

        System.out.println("customer " + customerId + " wakes up");
        customerPaid++;
        System.out.println("customer " + customerId + " payes");
        sleep.signalAll();

        lock.unlock();
    }
}
</code></pre>

<p>This logic uses integers. Since this is a threaded context I want to use booleans now instead of integers to avoid overflows. </p>

<p>So I came up with this. However this does not the same as the example above. What would be the right transformation?</p>

<pre><code>import java.util.concurrent.locks.*;

public class MassageSalon implements Salon{

    private boolean customerOnCouch = false;
    private boolean customerPaid = false;
    private boolean masseurAvailable = false;
    private boolean masseurBusy = false;
    private boolean masseurDone = false;
    private boolean masseurClose = false;

    Lock lock = new ReentrantLock();
    Condition sleep = lock.newCondition();

    public void getNextCustomer() throws InterruptedException{

        lock.lock();

        masseurAvailable = true;

        customerOnCouch = false;
        masseurBusy = false;
        customerPaid = false;
        masseurDone = false;
        masseurClose = false;

        System.out.println("masseur is available to handle a new customer");

        sleep.signalAll();

        //wait for next customer
        while(!customerOnCouch &amp;&amp; masseurAvailable){

            System.out.println("masseur sleeps");

            sleep.await();

            System.out.println("masseur wakes up");
        }

        //neuer kunde nimmt platz, masseur ist busy
        masseurBusy = true;

        System.out.println("masseur busy");

        lock.unlock();
    }

    public void finishedMassage() throws InterruptedException{

        lock.lock();

        //eventually the masseur finishes the massage

        System.out.println("eventually the masseur finishes the massage");

        masseurDone = true;

        sleep.signalAll();

        //and closes the deal as soon as the customer paid
        while(masseurDone &amp;&amp; !customerPaid){
            System.out.println("wait for payment");
            sleep.await();
        }

        System.out.println("and closes the deal as soon as the customer paid");

        masseurClose = true;

        lock.unlock();
    }

    public void getMassage(int customerId) throws InterruptedException{

        lock.lock();

        while(customerOnCouch  &amp;&amp; !masseurClose){
            System.out.println(customerId + " on couch waiting");
            sleep.await();
        }

        //takes couch
        customerOnCouch = true;

        System.out.println(customerId + " on couch");

        sleep.signalAll();

        while(masseurDone &amp;&amp; !customerPaid){
            System.out.println("customer " + customerId + " sleeps");
            sleep.await();
        }

        System.out.println("customer " + customerId + " wakes up");
        customerPaid = true;
        System.out.println("customer " + customerId + " payes");
        sleep.signalAll();

        lock.unlock();
    }
}
</code></pre>
