Reputation: 2348
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?
Upvotes: 1
Views: 177
Reputation: 245028
It seems IronRuby's puts
is not thread-safe. If you use Console.WriteLine()
in IR, it works fine:
System::Threading::Tasks::Parallel::ForEach([1,2,3,4,5,6,7,8], Proc.new {|x|
System::Console::WriteLine(x)
})
Upvotes: 2