ランダム変数を使用して正規分布を生成するWpfコードを書きました。C#でParallel.forが動作していません
using System.Threading.Tasks;
using System.Threading;
private void Button_Click(object sender, RoutedEventArgs e)
{ .....
for (int t = 0; t < normalx.Count; t++)
{
normaly.Insert(t, (2/((Math.Pow(2 * Math.PI, 0.5)) * rmsnormalvalue)) * Math.Exp(-0.5 * Math.Pow(standardnormalx.ElementAt(t), 2)));
}
...
}
これはシントンコードです。並列スレッドとして実行するには
は、私が
Parallel.For(0, normalx.Count, t =>
{
normaly.Insert(t, (2/((Math.Pow(2 * Math.PI, 0.5)) * rmsnormalvalue)) * Math.Exp(-0.5 * Math.Pow(standardnormalx.ElementAt(t), 2)));
});
にこれを変更したが、ビルドは大丈夫ですが、実行時に一つだけのスレッド域(normalx.Count/8
< - 私のPCはi7のである)で
ました作業し、計算した。
どうしたのですか?
「normaly」とは何ですか?スレッドセーフですか? –