This topic has been archived. It cannot be replied.
-
工作学习 / 学科技术讨论 / 呼叫deep_blue,哪里有multi thread的C#知识啊。 到底要达到什么程度才可以做multi thread? multi thread到底有多难啊?
-tonyhao(tonyhao);
2011-11-14
(#7069340@0)
-
.net的multi thread,4.0推出了全新的TPL(Task Parallel Library),性能很好,自动利用thread pool,支持并行计算。4.0之前的multi thread,要主动利用thread pool达到性能最优。还有就是注意thread safe(monitor,lock等等)。班门弄斧,还望坛子里各位大佬指正
-binghongcha76(一只大猫);
2011-11-14
(#7070058@0)
-
If you Google .net multithreading tutorial, you’ll get thousands of results.In my personal option, multithreading is not hard to learn. To thread pool you need create delegate, event. If it is true as big cat mentioned that .NET 4 automatically handles thread pool, that makes things simple.
-deep_blue(BLUE);
2011-11-15
{215}
(#7070238@0)
-
刚看到的消息,Silverlight 5将支持TPL,这意味着以后Silverlight 5也将支持线程池并且也可以进行并行编程了...
-binghongcha76(一只大猫);
2011-11-17
(#7077436@0)
-
TPL indeed makes running multi-tasks (threads) very simple and easy.
-deep_blue(BLUE);
2011-11-17
(#7078447@0)
-
好多旧的CODE用的不是TPL。 用POOL的都是简单的吧。 手动的更值钱, 多数开价11万以上。
-tonyhao(tonyhao);
2011-11-21
(#7087405@0)
-
It looks like you ask me to help you to make big money.Next time I'll charge it for consulting. LOL
-deep_blue(BLUE);
2011-11-22
{46}
(#7088519@0)
-
原来你是考人家了。没啥特殊的东西,都在这啦==>
-tjhong(以后再说);
2011-11-22
(#7089291@0)
-
if you know this one, you mastered multithreading:
a method which loop 100 times to increase balance by 1. If the begining balance is 0. If two threads run at the same time, what is the mim and max balance?
-rv2843(rv2843);
2011-11-28
(#7105613@0)
-
如果data race处理好了,不就是200吗? 处理不好,鬼知道多少。
-tonyhao(tonyhao);
2011-12-4
(#7119336@0)
-
There is no synchronization. It tests your understanding of multithreading.
-rv2843(rv2843);
2011-12-7
(#7127033@0)
-
根本理解的一塌糊涂。你啥理解啊?
-tonyhao(tonyhao);
2011-12-8
(#7130680@0)
-
minimum is 2. You need to simulate two threads in your mind to see what kind of scenario they could have.
-rv2843(rv2843);
2011-12-9
(#7132271@0)
-
"minimum is 2"怎么得出来的?不理解你的题目意思,再小也不可能小于单个线程算出来的值吧。
-tjhong(以后再说);
2011-12-9
(#7133107@0)
-
如果是两个线程都结束的结果,那是永远200的,相当于2个人往空筐里每次扔一分钱硬币,每人扔100次,跟次序没关系。
-tjhong(以后再说);
2011-12-9
(#7133143@0)
-
haha, then why do we need syncrhonization.
-rv2843(rv2843);
2011-12-14
(#7143301@0)
-
I will reveal the answer later to give some people time to think it over.
-rv2843(rv2843);
2011-12-14
(#7143305@0)
-
爽气点,N天回个贴不觉得太慢啦。
-tjhong(以后再说);
2011-12-14
(#7143370@0)
-
increase balance by 1 should stand for some long time job, but not just balance++,right?
-tonyhao(tonyhao);
2011-12-10
(#7134387@0)
-
你的问题应该有些假设的,一个cpu, 几个cpu共享内存,多核cpu等,计算结果是否是volatile variable,可能答案不一样了。
-goodchoice(buff);
2011-12-9
(#7134088@0)
-
only assumption is read is atomic and write is atomic. Increase is operations of read and write.
-rv2843(rv2843);
2011-12-14
(#7143290@0)
-
two threads T1 & T2.
T1 reads 0, then suspended.
T2 increase for 99 times, then suspended.
T1 resumes and write, balance = 1.
T2 reads 1, then suspended.
T1 resumes and finishes.
T2 writes => balance = 2.
-rv2843(rv2843);
2011-12-15
(#7145118@0)
-
理论上可能吧。不过两个thread的代码一样,想做出这个结果来也难。int Icount = 0;
void ThreadMethod()
{
for (int i = 0; i < 100; i++)
{
Icount++;
System.Threading.Thread.Sleep(0);
}
}
-tjhong(以后再说);
2011-12-15
{219}
(#7145180@0)