in reply to Re^2: Net::SSH2 not thread safe?
in thread Net::SSH2 not thread safe?

I need to control the number of threads spawned, thus I would need to pass it into pssh in batches of $threads.
Net::OpenSSH::Parallel already does that for you. For instance, if you want to limit the number of SSH connections to 10, you can use:
my $pssh = Net::OpenSSH::Parallel->new(connections => 10);