Hi
I have a weather forecasting program that uses a few threads. These threads stop and start at different times throughout the program so there is no set amount of threads at one time. My problem is when i try and close the main thread the program keeps going because there are still threads alive.

Seeing as the threads which are alive change all the time i was wondering if there was any way to kill all threads.

Any help would be greatly appreciated :)

Recommended Answers

All 3 Replies

Could your main thread keep a dynamic dictionary or list of the process ids ? Then you could perform some basic system commands to see which theads are still running and kill them if necessary?

Well when you fork a new process, the process ID is returned, so you would append that to a list... then when you're ready to quit, iterate through the list issuing system calls to kill each process.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.