Change the yield in your MainReaper thread to:
sleep 1 until ($DoneFlag || $Timeout);
Yield just relinguishes the rest of the threads timeslice. It immediately becomes eligible for rescheduling. That means that if no other thread is available to run, you've coded a very tight loop that will happily consume as much cpu as is available. By using a sleep, you will avoid thrashing the cpu. If you need finer than 1 second resolution, use Time::HiRes::sleep or the 4-arg select.
Note: This is based upon my observations of what happens on Win32. Your OS may work differently.
In reply to Re: CPU Leaking Threads
by BrowserUk
in thread CPU Leaking Threads
by Trizor
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |