my @threads; for my $i (1..2) { push @threads, threads->create(\&testsub, $dbh->clone()); } foreach my $thread (@threads) { $thread->join(); } sub testsub { for my $key (@{$_[0]->selectcol_arrayref("SELECT id, sleep(0.1) FROM keywords WHERE 1")}) { print $key; } }