Creating and handle threads to calculate the prime numbers until given m