for( i = arg->begin; i < arg->end; i++){
x = (i + 0.5) * width;
x = 4.0 / (1.0 + x * x);
EnterCriticalSection(arg->cs);
pai += x;
LeaveCriticalSection(arg->cs);
}
double p = 0;
for( i = arg->begin; i < arg->end; i++){
x = (i + 0.5) * width;
x = 4.0 / (1.0 + x * x);
p += x;
}
EnterCriticalSection(arg->cs);
pai += p;
LeaveCriticalSection(arg->cs);