in reply to Re: Threading and join/termination question
in thread Threading and join/termination question

Thanks for the reply. Yes I discovered that mistake. Thought the "= 1" was a flag or something.

Anyway when I ran this, I still only got 0 1 2 3 in the last line of output, so it was missing 4 and 5. Thinking maybe the script was terminating before the threads finished, I tried adding

while (threads->list()) { sleep 1; }
after the for loop. That took care of it. Interestingly, I first tried .1 for the sleep argument and only got the 4. I don't understand that. Doesn't seem like a push should take that long.

Replies are listed 'Best First'.
Re^3: Threading and join/termination question
by choroba (Cardinal) on Aug 01, 2014 at 13:11 UTC
    sleep doesn't handle real numbers, it takes only the int part of its argument.
    لսႽ† ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ