use strict; use warnings; use threads; my $thread_count = 0; while (1) { threads->new(\&handle_thread,++$thread_count); sleep .1; } sub handle_thread { my $thread_count = shift; threads->self->detach; # so long parent print "You are thread number $thread_count \n"; sleep .2; }