http://www.perlmonks.org?node_id=1059083

ThelmaJay has asked for the wisdom of the Perl Monks concerning the following question:

Dear Masters,

I'm relatively new to Perl.

I'm with a multi-thread dilemma :).

To implement a multitask environment I used Forks (Parallel::ForkManager). But I think forking is not the solution I need.

I create 50 forks each one is responsible for parsing a stream.

But if one of the streams is bigger than the other 49, these 49 instead of starting to parse new streams they have to wait for the one that is taking more time to process.

How can I "unblock" the other threads? Is forking the solution?

My code:

my $pm = Parallel::ForkManager->new(50); my $i = 0; while(i<50){ $pm->start and next; processStream($stream); $i++; $pm->finish; # do the exit in the child process } $pm->wait_all_children();

If I remove wait_all_children() what would happen?

Best Regards, thank you for your help.