sub _replicate{ ... foreach my $k(0..$#thr_arr){ print $k," ",$sc->{rsync}->[$k]->{thr}, $/; if ($sc->{rsync}->[$k]->{thr} eq 'running'){ my $t = $thr_arr[$k]; my $th = threads->object($t); $th->join() if ($th); } } ... }