I am using BlockingQueue in a multi threading system where a synchronized block adds items to the list. Sometimes it does not add items to the list, items that it misses are random.I tried to add following line to the code and then it never missed any item.
list.forEach(item -> logger.info(" In list "+item));
I feel this behaviour is kind of strange. Can someone please help me figure out how can I resolve this problem of missing file? I do not want to unnecessarily iterate over the entire list. Am I missing something in this?