#!C:\Perl\bin\perl -w print "Content-type: text/html\n\n"; use warnings; use Time::HiRes; use threads; use threads::shared; $doc_top = "\n"; $doc_top .= "\n"; $doc_top .= "\n\n"; $doc_top .= "\n"; $doc_top .= "\n\n"; $doc_top .= "\n"; $doc_top .= "\t\n"; $doc_top .= "\t\t\n"; $doc_bottom .= "\t\n"; $doc_bottom .= "
\n"; $doc_middle =''; $doc_bottom .= "\t\t
\n\n"; for ($j = 0; $j <= 32; $j++) { $doc_middle .= "\t\t\t\n"; for ($i = 0; $i <= 2; $i++) { $doc_middle .= "\t\t\t\t \n"; } $doc_middle .= "\t\t\t\n"; } print $doc_top.$doc_middle.$doc_bottom; print "\n"; $|++; my $threads = 3; my $count : shared = $threads; my @threads; my @params = ( {id => '0', up => 8, to => 0.5, char => 'a'}, {id => '1', up => 5, to => 0.2, char => 'b'}, {id => '2', up => 11, to => 0.3, char => 'c'}, {id => '3', up => 6, to => 1.1, char => 'd'}, {id => '4', up => 2, to => 0.5, char => 'e'}, {id => '5', up => 9, to => 0.6, char => 'f'}, {id => '6', up => 3, to => 0.7, char => 'g'}, {id => '7', up => 5, to => 0.8, char => 'h'}, {id => '8', up => 6, to => 0.9, char => 'i'} ); sub fun { my $arg = shift; $count -= 1; my $cur_var = 0; for($cur_var = $cur_var; $cur_var <= $arg->{up}; $cur_var++) { redo if $count; print "\n"; Time::HiRes::sleep($arg->{to}); } } foreach(1..$threads) { push @threads, threads->new(\&fun, shift @params); } foreach(1..$threads) { my $thid = shift @threads; $thid->join; } print "\n"; print "\n";