my @threads; for (1..$listeners) { push @threads, threads->create(\&handleConnection, $main_sock); } $_->join for @threads;