Código PHP:
#include <iostream>
#include <pthread.h>
using namespace std;
unsigned long m=10;
double f (double x){
return 4.0/(1+x*x);
}
double calcula(){
double suma = 0.0;
for (unsigned long i=0 ; i < m ; i++)
suma += f ((i+0.5)/m);
return suma/m;
}
int main (){
pthread_t hebra1, hebra2;
pthread_create (&hebra1, NULL , f, NULL);
pthread_create (&hebra2, NULL, calcula, NULL);
pthread_join (hebra1,NULL);
}