sub second { ## creating 5 threads for ($i ; $i<5;$i++) { $array_of_threads[$i]=threads->new(\&sub1,"$i"); print "End of thread ".int($i+1)." creation\n"; } $_->join for @array_of_threads; ## Add this &complete(); }