In C#
class ParallelTest
{
public static void Main()
{
System.Threading.Tasks.Parallel.ForEach(new []{1,2,3,4,5,6,7,8},
x => { System.Console.WriteLine(x); }
);
}
}
Result
4
5
6
7
8
2
1
3
But, in IronRuby(1.1.3).
Some line empty or lose linefeed.
System::Threading::Tasks::Parallel::ForEach([1,2,3,4,5,6,7,8], Proc.new {|x|
puts x;
})
Result
1734
2
5
6
8
What coused this problem?
Is this just a bug?
It seems IronRuby’s
putsis not thread-safe. If you useConsole.WriteLine()in IR, it works fine: