use threads; use strict; use CGI qw(:standard); use CGI::Carp qw(warningsToBrowser fatalsToBrowser); use Test; print header('text/html'); my $r = shift; my $MAX_THREADS = 5; my @res; for my $i (1 .. $MAX_THREADS) { threads->create('Test::thr_func', $i*2); } print "Here I am!\n"; while (threads->list()) { sleep 1; print "running...\n"; foreach my $thread (threads->list(threads::joinable)) { if($thread->is_joinable()) {; push(@res, $thread->join()); } } } print "That's all folks!\n"; #Here goes the end of html code