Parameterized the number of threads