In a producer consumer pattern using ExecutorService what if all threads starts executing the consumer task and blocks themselves waiting for the producer to push data indefinitely?
Can this ever happen ?? If I have say X no of Url's to download and then parse the content and store in a database. I use producer and consumer analogy of multithreading to solve the problem.
The producer will download the content and place the data into a BlockingQueue of size Y (say Y
Now say I create a thread pool of N no of threads where N << X. Add I assign X number of producer task and X no of Consumer task.
In such as case if all threads execute the consumer task and gets blocked when it tries to collect data from the blocking queue.Then basically I am left with no Thread to execute the producer task and I am in a stalemate.