Code example for Monitor

Methods: enterWhenleave

0
            return (list.size() < MAX_SIZE); 
        } 
    }; 
 
    public void addToList(String item) throws InterruptedException {
        monitor.enterWhen(listBelowCapacity);
        try { 
            list.add(item);
        } finally { 
            monitor.leave();
        } 
    } 
} 
Stop searching for code, let great code find you!  Add Codota to your java IDE