in reply to Question about threads

If you are on a *NIX box, type cat /proc/cpuinfo to see how many processors you have on the machine this code runs on. Remember, multi-threading works better on a multi-processor box.

Having said that, why aren't you being more general? You have a subroutine for each thread that does the same thing:

sub australianNationalUniversity { use AustralianNationalUniversity; AustralianNationalUniversity::search( $maxHits, %searchTerms ); my @results = AustralianNationalUniversity::getResults(); lock(@searchResults); push ( @searchResults, @results ); }
You should generalize that. Something like this untested piece of code:
# at the beginning of your code: use GenericSearch; # and then just ONE sub for all threads sub get_search { my $group = shift; GenericSearch::search($group, $maxHits, %searchTerms ); my @results = GenericSearch::getResults(); lock(@searchResults); push ( @searchResults, @results ); }
Also, why hold each thread in a seperate variable? Why not store them in an array instead? Because you have 13 seperate search items? Nonesense! Just "tag" them with a leading underscore (or whatever) so you can grep them out of CGI::param() like so:
my @search = grep /^_/, param(); # now remove the underscores $_ = substr($_,1) for @search; # now create the threads; my @thread = map { threads->new(sub {get_search($_)})}, @search; # and finally, join them when done $_->join for @thread;
Code smart, not hard. ;)

jeffa

L-LL-L--L-LL-L--L-LL-L--
-R--R-RR-R--R-RR-R--R-RR
B--B--B--B--B--B--B--B--
H---H---H---H---H---H---
(the triplet paradiddle with high-hat)