It seems You are mixing old-style and deprecated threads model(Thread module) with the new ithreads thread model (threads module). Creating the threads should be done like this:
$thread = threads->create( \&do_stuff, param1, $param2 );
Please also note that indirect object notation like new Class is discouraged in Modern Perl in favor of Class->new.
If You do care about worker threads finishing their jobs You should use join() instead of detach() so You don't need the second while loop. Please see the perlthrtut for a more thorough explanation.
Please give the Perl version and OS You are running this, so the monks here can suggest better alternatives to Your current code.
You can also find valuable information regarding threads programming in Perl from fellow monks BrowserUk, ikegami, zentara.
Looking forward to Your reply!
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
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:
Outside of code tags, you may need to use entities for some characters:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, 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, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.
| & || & |
| < || < |
| > || > |
| [ || [ |
| ] || ] ||