Well the OP said he was running some
heavy code from the threads. So that probably means he's going to be importing some modules, like CGI, DBD, PDL?, whatever.....and that code will now be incorporated into the next spawned thread, in the copy-on-create process. This is going to cause problems in subsequent generations.... as it's parent was contaminated by previous code.
Your interesting solution, would require spawning 1 primordial virgin thread, which is used for nothing more than to spawn more clean threads.
Because that virgin copy, cannot import any modules, without polluting it's own next copy, it can only have a breeder function.
Having that breeder thread laying there, just to spawn more, is quite wasteful.
On linux, there comes a time to fork. I advocate forking from the threads, so that the threads only get created once, and act as controllers for the forked code they run.
This is the big difference between threads on Windows and Linux. On linux, there is a distinction between forking and threads, whearas on Windows fork() is emulated.
On linux, forking code has many advantages over threads, the memory cleanups are better, and probably faster, and thread safety of modules becomes a non-issue.
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.