class Monitor { private Item buffer = new Item(); private int count = 0; public synchronized void insert(Item item) { // ... } }