业精于勤

导航

2011年11月15日

线程安全 二

摘要: usingSystem;usingSystem.Threading;abstractclassCounter{protectedintcount=0;publicabstractintRead(intthreadNum);publicabstractvoidIncrement(intthreadNum);}//NotethattheinstancevariablecountissharedbetweenthetwomethodsRead//andIncrement.Threadsconcurrentlyexecutingoneorbothofthesemethodscan//interfere 阅读全文

posted @ 2011-11-15 11:41 言午 阅读(190) 评论(0) 推荐(0) 编辑

线程安全 一

摘要: usingSystem;usingSystem.Threading;usingSystem.Runtime.Remoting.Contexts;usingSystem.Runtime.CompilerServices;//NotethattheinstancevariablecountissharedbetweenthetwomethodsRead//andIncrement.Threadsconcurrentlyexecutingoneorbothofthesemethodscan//interferewitheachotherunlessactionistakentosynchronize 阅读全文

posted @ 2011-11-15 11:40 言午 阅读(203) 评论(0) 推荐(0) 编辑