Synchronized implementation : Java
问题 This is a Consumer-Producer problem in which, I wish to get output as follows: Put: 0 Get: 0 Put: 1 Get: 1 ....and so on. But in contrast to this, the Consumer class consumes same value of q multiple times, inspite of using wait() and notify() methods.. as well as the Producer class overruns the consumer. How can I get synchronized output? This is QFixed class:(which defines put() and get() methods) class QFixed{ int n; boolean valueset = false; synchronized int get(){ if(!valueset){ try {