Why is this multithreaded program getting stuck at infinite loop?
问题 The below program is a simple threaded program . For some reason which i am not able to figure , its getting stuck at infinite loop of both produce() and consume() methods simultaneously in both the threads. It produces the output for a few times and then there is no output at the console. So I presume its getting stuck at the loop. My question is , since the loop depends on the value of the flag valueSet of the same object of Item class , valueSet can't be both true and false at the same