Link to home
Start Free TrialLog in
Avatar of elcoco
elcoco

asked on

Killing a Thread within a process.

Is there a way to kill a ind. thread within a process
Avatar of elcoco
elcoco

ASKER

Edited text of question
ASKER CERTIFIED SOLUTION
Avatar of nebeker
nebeker

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
More info please!
what's an 'ind. thread'?
Are you in the same process?
Do you have the process ID?
Does the thread need to do any cleanup?
Is the thread likley to terminate itsself? (ran into this one, OS/2 reuses thread IDs so if you ask thread N to die, and it does, and another  one starts with thread ID N, and then you kill thread ID N thinking it;s the original one still hanging around, you;re in trouble!)

The quick answer is DosKillThread()

Avatar of elcoco

ASKER

thanks, i have an oem package that is creating threads but not cleaning them up. therefore i eventually run out of avail. threads.  the manufact. is slow to resolve this is.  i'm trying to either create a work around or another app. that could close threads that have been inactive. i dont know if this is possible from your answer....would be grateful for any help you can provide
As far as I know, one process cannot kill individual threads from another process.

If you were to shut down the offending process, all of its dead threads would go along with it.  Is there any way you can "restart" the problematic program every once in a while?  (Kind of like the trick used to keep Windows NT servers running - reboot them every night at midnight <g>)

In order for your system to truly run out of available threads, this process must be creating hundreds of them....  How long does it take to run out, and how many threads are in the system when it finally dies?
Another problem qould be determining which of th threads are idle.
Why not just bump up the threads to the max (4095)?
That should keep the app busy chewing them up for a while.

Avatar of elcoco

ASKER

Thanks, i have already bumped them up to 4095...the app does open quite a bit of
 threads. its opening an sql table and writing to an ascii file. it will open a thread for each
read AND write. it does this hourly for approx. 40 files with two data pieces a piece and the threads are exhausted after a few days....i can reboot this system,but the problem becomes automating the process. i guess i can figure something out. since i dont have the source code i cant fix and recompile.