Producer-Consumer problem written in Java