Optimize #necessary threads spawned