You need to reuse your threads. It's a misconception that if you use detach, that somehow it all dissppaears after the thread is finished and the memory is reclaimed to the system. It is reclaimed to Perl.
So what you need to do, is NOT detach, and work out a scheme to reuse your thread threads. I usually put them in a "sleeping condition", and have them periodically check to see if they should wake up and do something. It dosn't use much cpu for a thread to sleep and wake up every 50 milliseconds( or even 1 second).
You may also be able to use detach , but just reuse the variable name you assign to the thread, but I havn't tested that much. All this is complicated by what you are using in your thread. Try to keep all extra objects contained completely within each thread. But it is all so complex, that you really need to show some code example, then we can help you work out solutions.
I'm not really a human, but I play one on earth.
flash japh
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.