When 11 is executed it will read the value of i from main, but you don't know when this will happen so you don't know what the value is going to be.
This is what I thought, but since i is assigned before the thread is created i still found the output
thread--- 0
thread--- 0
strange.
Last edited on
It's not strange. You set i to 0 again in the last loop.
Last edited on
Hi,
That is a nice thread.
I have a question, where is the mutex being locked by each thread?
I only see it getting unlocked by each thread.
Thank you.
BTW, where did you gain that Linux knowledge?
I'm trying to get into Operating Systems world, and into Linux specifically.