Producer Consumer – the saviour!


I had a task of populating some collections several times,  before uploading them to DB. What happened was, memory had grown rapidly, and atlast the application died with OutOfMemoryError 😦

That time my lead was suggesting to go to this pattern, Producer-Consumer!  Like, one guy will be populating the collection, In parallel another guy will be reading from the collection and update the db! Wonderful man, this design is highly scalable, if you implement correctly! For more info, see the simple example here,