随笔分类 - 多线程
摘要:WaitAll vs WhenAll 回答1 Task.WaitAll blocks the current thread until everything has completed. Task.WhenAll returns a task which represents the action
阅读全文
摘要:When does a C# Task actually start? Calling an async method returns a hot task, a task that has already been started. So there is no actual code neces
阅读全文
摘要:经过测试发现,多线程操作都是安全的。甚至包括在遍历的时候,进行删除操作 https://github.com/ChuckTest/ConcurrentTest class Program { private static readonly ConcurrentDictionary<int, int>
阅读全文
摘要:When Iterating Over ConcurrentDictionary and only reading, is ConcurrentDictionary locked? https://referencesource.microsoft.com/#mscorlib/system/Coll
阅读全文
摘要:ArrayList.Synchronized Method Returns a list wrapper that is synchronized (thread safe). The following code example shows how to lock the collection u
阅读全文
摘要:ConcurrentBag of strings and using .Contains in Parallel.ForEach The collection is threadsafe, as in "using it concurrently won't corrupt its state".
阅读全文
摘要:Reentrant mutex In computer science, the reentrant mutex (recursive mutex, recursive lock) is a particular type of mutual exclusion (mutex) device tha
阅读全文
摘要:Reentrancy (computing) In computing, a computer program or subroutine is called reentrant if multiple invocations can safely run concurrently. The con
阅读全文
摘要:https://docs.microsoft.com/en-us/dotnet/api/system.threading.thread.join?view=netframework-4.7.2 https://docs.microsoft.com/en-us/dotnet/api/system.th
阅读全文
摘要:Why is lock(this) {…} bad? https://stackoverflow.com/questions/251391/why-is-lockthis-bad It is bad form to use this in lock statements because it is
阅读全文
摘要:http://stackoverflow.com/questions/9415955/c-sharp-working-with-entity-framework-in-a-multi-threaded-server https://blogs.msdn.microsoft.com/alexj/200
阅读全文
摘要:http://stackoverflow.com/questions/1050222/concurrency-vs-parallelism-what-is-the-difference Concurrency is when two or more tasks can start, run, and
阅读全文
摘要:http://stackoverflow.com/questions/4130194/what-is-the-difference-between-task-and-thread 回答一: A task is something you want done. A thread is one of t
阅读全文
摘要:https://msdn.microsoft.com/en-us/library/z6zx288a(v=vs.110).aspx The System.Threading.Semaphore class represents a named (systemwide) or local semapho
阅读全文
摘要:https://msdn.microsoft.com/en-us/library/system.threading.semaphoreslim(v=vs.110).aspx Represents a lightweight alternative to Semaphore that limits t
阅读全文
摘要:http://www.albahari.com/threading/part2.aspx#_Mutex A Mutex is like a C# lock, but it can work across multiple processes. In other words, Mutex can be
阅读全文
摘要:http://www.albahari.com/threading/part2.aspx#_Semaphore A semaphore is like a nightclub: it has a certain capacity, enforced by a bouncer. Once it’s f
阅读全文
摘要:private static readonly AutoResetEvent autoResetEvent = new AutoResetEvent(false); private static void Main() { try { Console.WriteLine("{1}线程={0}", T
阅读全文
摘要:http://stackoverflow.com/questions/1355398/monitor-vs-waithandle-based-thread-sync A problem with Monitor.Pulse/Wait is that the signal may get lost.
阅读全文
摘要:https://msdn.microsoft.com/zh-cn/library/system.threading.threadpool(v=vs.110).aspx 最基础的 线程池QueueUserWorkItem中方法没有执行 https://stackoverflow.com/questio
阅读全文