$thr_1->detach();
####
$thr_2 = threads->create('func_thr_2')->detach;
####
#!/usr/bin/perl
use strict;
use warnings;
use threads;
my $thr_1;
my $thr_2;
my $timer = 3;
my $res;
$thr_1 = threads->new('func_thr_1');
$thr_2 = threads->create('func_thr_2')->detach;
$res = $thr_1->join();
print "exit code is: $res\n";
print "\nend\n";
sub func_thr_1 {
my $cc = 0;
print "thread 1 is running\n";
while ($cc <= 10) {
print "cout is $cc\n";
sleep 1;
$cc++;
}
return 'success';
}
sub func_thr_2 {
while ($timer >= 0) {
$timer--;
sleep 1;
}
print "\nTime up\n";
}