Joining Threads

December 1, 2013

This morning I tried to keep working on my Daily Weight app, but kept getting distracted by my Longest Streak app which was having troubles running for long periods of time. I’ll talk more in depth about some of the issues I’ve been having, but the main one that I was running into has to do with thread.join.

I create a loop of around 100 threads that go and fetch the profile pages of each of the users and then I join all the threads before requesting more users. The problem I’m currently facing is that randomly sometimes thread.join never finishes. I’ve left it running for over an hour before and it never finished. The only option at this point was to kill the app and then start it up again.

But just now looking at the documentation for Thread it looks like there is a limit parameter I can pass it which may solve my problem I’m having. There also are more methods that should come in handy like status, stop, exit, and kill.

I also should mention that I did try removing the thread.join completely, but that just made the program run super slow. I think it just made way too many threads and bogged down system.