Number of threads is now an input parameter