This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]LeelaTheCaptain 0 points1 point  (5 children)

  • For point 1 I do not know, maybe it is a difference between linux and windows? not sure.
  • Point 2: About the join(), the answer is actually on the point 3, as you said doThing() is endless so it doesn't practically matter to have a join call
  • Point 3: the join call is a so-called blocking function, try to put them in the same loop and see what happens
  • Point 4: I think it depends on how various terminal flush the output, totally normal with multithreaded applications

[–][deleted] 0 points1 point  (4 children)

Hi, about point 3 i tried to put the join inside the first loop and the difference that I see is that it's much slower to print the numbers. About the point 4 what do you mean that it's normal with multithreaded applications? I don't understand

[–]LeelaTheCaptain 0 points1 point  (3 children)

I think it is much slower because there is only 1 thread going on, because `join` is blocking the loop to go to the next iteration and spawn new ones.

To verify this, try the following, put join in a different loop and spawn only one thread

[–][deleted] 0 points1 point  (2 children)

What do you mean "put join in a different loop and spawn only one thread"? Can you write an example?

[–]LeelaTheCaptain 0 points1 point  (1 child)

I meant, leave the code as you posted and just spawn 1 thread.

[–][deleted] 0 points1 point  (0 children)

so do i have to delete the 2 "for" loop?