Infibeam Interview Question
SDE-2sCountry: India
Interview Type: Phone Interview
could you clarify the question? maybe the class LinkedBlockingQueue could be used for such purposes.
The interviewer told not to use any BlockingQueue implementation there in Java inbuilt.
The discussion moved on from a standard producer / consumer implementation in which we have to use our own BlockingQueue implementation.
For standard producer-consumer implementation you can refer:-
hxxp://javarevisited.blogspot.sg/2012/02/producer-consumer-design-pattern-with.html
@hulk stop spaming with your fake interview questions. Some people want to prepare themselves for the real interview instead of solving your study problems.
I know the rules very well. If this was a non-interview question I would have posted this in Forums not here.
Now coming to this question, if you have given interview in any decent product company for mid-level java role then you will know that this is quite common multi-threading question.
In fact I was asked this same question in two companies :)
Definition of Producer- Consumer problem from wikipedia:-
- hulk May 03, 2014" The producer and the consumer, who share a common, fixed-size buffer used as a queue. The producer's job is to generate a piece of data, put it into the buffer and start again. At the same time, the consumer is consuming the data (i.e., removing it from the buffer) one piece at a time. The problem is to make sure that the producer won't try to add data into the buffer if it's full and that the consumer won't try to remove data from an empty buffer."
In this case instead of a single producer producing data and single consumer consuming there can be multiple producers producing data and multiple consumers consuming them.