I wrote one software that uses ThreadPool for multithreading.
ThreadPool.SetMinThreads(128, 128);
ThreadPool.SetMaxThreads(512, 512);
for (int i = 0; i < 40; i++)
{
ThreadPool.QueueUserWorkItem(_ =>
{
Console.Write("!");
Thread.Sleep(1000);
Console.Write(".");
}, null);
}
Inside each thread I perform blocking network operations(work with http). Software designed around blocking network model and I cannot move to non blocking 1 threaded I/O.
It works perfect on windows platform, I can use 128-512 threads per one core without any issues, all work as it should work. But when I moved to mono, I saw some really strange behaviour. I cannot make mono run many threads per one CPU core, max I can get - 1 thread per core, doesn't matter what I do specify in SetMinThreads/SetMaxThreads.
tried under Linux with .NET 4/4.5, MONO version 3.2.1 and some older version on my previous system. Btw, plain threading code works well, for example this gives desired result:
for (int i = 0; i < 20; i++)
{
var t = new Thread(_ => {
Console.Write("!");
Thread.Sleep(1000);
Console.Write(".");
});
t.Start();
}
We've also experimented alot with mono and looks that following helps:
We're using both options and mono on linux acting quite fast( comparable to .net on windows )
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With