So, there is a project, rather big, not mine.
There is a test case/example. However the code doesn't finish. Or rather after finishing the application still runs.
I did classical debug - it just went to the end and that's it. Yet the application runs. I know for certain, that there are couple threads running concurrently (but they shouldn't have to). How to close all threads? Or to be more precise: how to close all threads instantiated by a class?
A classic approach for such scenarios is to use join method in the end of method which spawns the threads. That way, you could exit after all the threads(or the threads which you join) are finished.
By the way, can you provide some more details about the behavior of project? Is there any specific reason to keep some threads alive for a long time?
Or it might be a straightforward scenario in which threads do take more time to finish their work, right? In that case, even if you debug main thread, it will finish first and spawned threads would still be running.
Justin Thomas wrote:You gave me a good idea about what and where to look.
And I found 2 bugs in the code :)
I have ever seen.
That's not necessarily a bad thing. It's a pretty common idiom, although you do need to provide some other way to end the loop. (Personally, I generally avoid that idiom, in favor of something like while (!done()).
That's a bug?
It's just a flesh wound! Or a tiny ad:
Sauce Labs - World's Largest Continuous Testing Cloud for Websites and Mobile Apps