C#????????
???????????? ???????[ 2015/9/16 13:24:20 ] ????????.NET ???????????
????2. ??? Barrier ?????
?????????????????????????????????????????? Wait ?? Pulse ???????????FrameWork 4.0??????汾????????? Barrier ??????????? Wait / Pulse ?????????????????????????????????
class Program
{
private static Barrier _barrier;
private static void Main(string[] args)
{
var fileNames = new List<string> { "A"?? "B"?? "C"?? "D" };
// ????????????
fileNames.ForEach(name =>
{
if (!File.Exists(name))
File.Create(name).Close();
else
{
using (var sw = new StreamWriter(name))
sw.Write("");
}
});
// ??_barrier?????SignalAndWait??????????????????????????4??
_barrier = new Barrier(4);
_sws = fileNames.Select(File.AppendText).ToList();
// ????????4????????????
var threads = new List<Thread> {
new Thread(() => Work(1))?? new Thread(() => Work(2))?? new Thread(() => Work(3))?? new Thread(() => Work(4))
};
threads.ForEach(t => t.Start());
// ?????????????? StreamWrite
threads.ForEach(t => t.Join());
Console.WriteLine("????????");
_sws.ForEach(sw => sw.Close());
}
static void Work(int threadIndex)
{
var next = threadIndex - 1;
for (int i = 0; i < 100; i++)
{
var sw = _sws[next];
lock (sw)
{
sw.Write(threadIndex);
}
_barrier.SignalAndWait();
next = (next - 1) < 0 ? 3 : next - 1;
}
}
}
???????????? Barrier ???????4???????????????? SignalAndWait ?????????????????????????4?Ρ??????????????ζ??4????????????????????????????????????? Barrier ??
???????????????????????漰???????????????????SPASVOС??(021-61079698-8054)?????????????????????????
??????
???????C#?е?StringC# Socket???????????????????C#?????????????????????????C#???????C#????????????Log4net??????δ????C#?????????????C#?????????????????C#???????????????C#????????????????C#7 ?е?Tuple??????C#??TypeScript - GeneratorC# ?????????細(xì)??????????C#?е???н???C#??MySQL?????????μ??Ч?????д??C#????C++??dll???C#??VS2010????е??????
???·???
??????????????????
2023/3/23 14:23:39???д?ò??????????
2023/3/22 16:17:39????????????????????Щ??
2022/6/14 16:14:27??????????????????????????
2021/10/18 15:37:44???????????????
2021/9/17 15:19:29???·???????·
2021/9/14 15:42:25?????????????
2021/5/28 17:25:47??????APP??????????
2021/5/8 17:01:11????????
?????????App Bug???????????????????????Jmeter?????????QC??????APP????????????????app?????е????????jenkins+testng+ant+webdriver??????????????JMeter????HTTP???????Selenium 2.0 WebDriver ??????