Fix Thread handling for NetBSD

Found by redent, modified his patch to fix the pthread handling.