Monte Carlo pi calculation with multithreading