use threads; sub my_sub() { return 1; } while (1) { my $thr=threads->create(\&my_sub); my @res=$thr->join(); }