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

Need some help. Currently the program is running 4 separate threads, pulling data off a queue to establish it's given task. The sub runs a while loop based off the queue's pending function. The threads all exit their while loops correctly. However after the sub should be done, the joins never occur. I can't quite figure out what's causing the lockup. Any help would be appreciated. Here's the censored version of the code:

sub smtpblast{ my $mdq= shift; my $pending= $mdq->pending; while($pending>0){ my $md= $mdq->dequeue_nb; my $user= $maildrop{"$md" . "user"}; my $pass= $maildrop{"$md". "pass"}; print "\n $user \n $pass \n"; my $mailer=Net::SMTP_auth->new('****'); $mailer->auth('Login', $user, $pass); $mailer->mail("$user"); $mailer->to('****'); my @data=("Subject: Test Messages from $user\n", "E-mail Blast message + from $user\n"); $mailer->data(@data); $mailer->datasend(); $mailer->dataend; $mailer->quit; $pending= $mdq->pending; } $threadid=threads->self; print "\n The process for thread $threadid is finished!\n"; } my $mdqueue=Thread::Queue->new(); $mdqueue->enqueue("md01", "md02", "md03", "md04", "md05", "md06", "md0 +7", "md08", "md09", "md10"); $thr1=threads->new(\&smtpblast, $mdqueue); $thr2=threads->new(\&smtpblast, $mdqueue); $thr3=threads->new(\&smtpblast, $mdqueue); $thr4=threads->new(\&smtpblast, $mdqueue); $thr1->join; print "\n Thread $thr1 joined! \n"; $thr2->join; print "\n Thread $thr2 joined! \n"; $thr3->join; print "\n Thread $thr3 joined! \n"; $thr4->join; print "\n Thread $thr4 joined! \n";

The program is for testing mail server latency. I have edited out server information and omitted the has that contains the logins. This is all the relevant pieces of code though.