Why there is late printing of 0 in published 0, if queue is being used

Sir if we are using the queue which has all the required locks then why in the output published 0 is not coming i:e 0 is coming after published 1 , published 2. It should be like published 0 consumed 0 .

Hello @i.m.anand_31, for understanding the concept we can say like this. But when the actual process is running on many things work out. Like which OS you are using which compiler, how many other applications are opened, how many spaces are there inside the RAM for the running of the program, which loop we are using while loop or for loop inside the code. So, the first 0 after consumed is the zero related to the published and the second 0 is related to the consumed.
And it is not guaranteed that this same output will come. Try writing the code and then execute that almost every time the output would be different.
So yes published 0 is also coming but when your system printed published and it was about to publish 0 but in the meantime,it printed the consumed and then 0 related to the produced.
As I said earlier it is a little bit confusing and it will take time to get the proper clearance of the concepts.

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.