I want to do some computation within a for loop:
for (int i=0; i< Math.Pow(10,8) ;i++){
//do some computation
}
but when I run, it only uses one of my cpu cores, (I see in task manager that my program uses 50% of cpu).
how can I use both cores? does it needs threading?
and also if it needs multi-threading ,I cannot break the loop because it fills an array and uses it as index increments ,so then what is the solution (if threading is needed).
for example in the code below , I fill array P as i increments and I use the array dynamically.
void f(){/*do some computation*/}
double[] P;
for (int i=0; i< Math.Pow(10,8) ;i++){
if (some conditions with index i and f and array P occurs )
P[i]=f;
}
my laptop is intel core 2 dou 2.2 GH.