Category Archives: Basic

BlockingQueue from java.util.concurrent package

There are times when you want, for performance reasons, one thread to produce objects and another one to consume it in parallel. You can definitely achieve this with the bare-bones thread API. But it might get a little messy depending on your exact use case (all that synchronize/wait/notify could drive you insane). And then what if the producer produces too fast and the consumer consumes too slow. Now you have too many objects queuing up in memory all waiting to get processed. Fear not – JDK Concurrent API is here to help.

Continue reading