#!/usr/bin/perl use threads; sub my_sub { open(my $fh, '>', "$0.".threads->tid() ) or die; print $fh 'text'; sleep(10); } threads->new(\&my_sub)->detach(); threads->new(\&my_sub)->detach(); sleep(2);