my @threads; for my $i (0..$#flags) { push(@threads, threads->new(\&worker, \$flags[$i]); }