Semaphore 的使用
作者:互联网
var workerSemphore = new Semaphore(0, 800000);
var IsWorkThreadCreated = true;
var workThread = new Thread(() =>
{
Console.WriteLine("XiaoweiSDK.CreateWorkerThread created!");
while (IsWorkThreadCreated)
{
//Debug.WriteLine("lock wait:XiaoweiSDK::CreateWorkerThread");
workerSemphore.WaitOne();
//Debug.WriteLine("lock enter:XiaoweiSDK::CreateWorkerThread");
Console.WriteLine("------------XiaoweiSDK.CreateWorkerThread inside inside inside!");
}
Console.WriteLine("XiaoweiSDK.WorkerThread exited!");
});
workThread.IsBackground = true;
workThread.Start();
Console.WriteLine("XiaoweiSDK.WorkerThread Release111111111!");
workerSemphore.Release();
Console.WriteLine("XiaoweiSDK.WorkerThread Release2222222222");
workerSemphore.Release();
标签:Console,XiaoweiSDK,Semaphore,WorkerThread,workerSemphore,WriteLine,使用,CreateWork 来源: https://www.cnblogs.com/bruce1992/p/15084102.html