tagged [concurrency]

What is a deadlock?

What is a deadlock? When writing multi-threaded applications, one of the most common problems experienced are deadlocks. My questions to the community are: 1. What is a deadlock? 2. How do you detect...

How can I use threading in Python?

How can I use threading in Python? I am trying to understand threading in Python. I've looked at the documentation and examples, but quite frankly, many examples are overly sophisticated and I'm havin...

How expensive is lock(...) when the lock isn't contended?

How expensive is lock(...) when the lock isn't contended? While looking into double-checked locking I've seen numerous recommendations to just skip the first check and immediately go for the lock and ...

Concurrency exceptions in Entity Framework

Concurrency exceptions in Entity Framework When calling `SaveChanges` / `SaveChangesAsync` in Entity Framework (CF, C#), if a change conflict occurs (for example, the values has been updated since las...

Any good implementation of Actors for C#?

Any good implementation of Actors for C#? Is there any good implementation of [actors concurrency model](http://en.wikipedia.org/wiki/Actor_model) for .net/c#? I have to optimize a c# routine and i th...

15 Apr at 22:44

Volatile vs Static in Java

Volatile vs Static in Java Is it correct to say that `static` means one copy of the value for all objects and `volatile` means one copy of the value for all threads? Anyway a `static` variable value i...

ADO.NET DBConcurrencyException - Trying to update an already deleted row

ADO.NET DBConcurrencyException - Trying to update an already deleted row Why is ADO.NET throwng a , when I try to update a row that is already deleted by another process, instead of just ignoring the ...

File.WriteAllText and Concurrent Accesses

File.WriteAllText and Concurrent Accesses Suppose I'm writing a very long string to a file using File.WriteAllText, and another thread or process is trying to read the same file. Would it throw any ex...

24 Jul at 08:31

ServerEventsClient concurrent model in ServiceStack

ServerEventsClient concurrent model in ServiceStack I use ServerEventsClient to listen for server events. Also I use JsonServiceClient, which available through the property ServiceClient of the Server...

27 Jul at 13:31

In .NET 4, does BeginInvoke and Task use the same threadpool?

In .NET 4, does BeginInvoke and Task use the same threadpool? .NET 4 introduced a brand new thread pool design accessed by the Task Parallel library. But if I have old code that uses Delegate.BeginInv...

10 Mar at 19:32

Visual Studio 2008 support for new .NET 4

Visual Studio 2008 support for new .NET 4 Will Visual Studio 2008 be supported by new .NET 4 from the get go? I'm particularly interested in the System.Collections.Concurrent namespace and the paralle...

Code demonstrating the importance of a Constrained Execution Region

Code demonstrating the importance of a Constrained Execution Region Could anyone create a that breaks, unless the `[ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]` is applied? I ju...

29 Aug at 01:22

Executing multiple functions simultaneously

Executing multiple functions simultaneously I'm trying to run two functions simultaneously in Python. I have tried the below code which uses `multiprocessing` but when I execute the code, the second f...

27 May at 09:41

What is the difference between a CLR Worker Thread and a Worker Thread?

What is the difference between a CLR Worker Thread and a Worker Thread? Looking at the Concurrency Analyzer, Threads view it appears my application produces far, far more threads than I would have tho...

Read only Dictionary - multiple threads calling .ContainsKey method

Read only Dictionary - multiple threads calling .ContainsKey method I have a static dictionary. modifications will be made to this dictionary. I have multiple threads reading from this dictionary usin...

Semaphore Wait vs WaitAsync in an async method

Semaphore Wait vs WaitAsync in an async method I'm trying to find out what is the difference between the SemaphoreSlim use of Wait and WaitAsync, used in this kind of context: ``` private SemaphoreSli...

What is the difference between SynchronizedCollection<T> and the other concurrent collections?

What is the difference between SynchronizedCollection and the other concurrent collections? How does `SynchronizedCollection` and the concurrent collections in the `System.Collections.Concurrent` name...

ConcurrentModificationException for ArrayList

ConcurrentModificationException for ArrayList I have the following piece of code: ``` private String toString(List aDrugStrengthList) { StringBuilder str = new StringBuilder(); for (DrugStrength...

18 Feb at 14:8

Fast and Best Producer/consumer queue technique BlockingCollection vs concurrent Queue

Fast and Best Producer/consumer queue technique BlockingCollection vs concurrent Queue Im using Generic.Queue in C# 3.0 and Monitor.Enter,wait,exit for wait before consuming the queue (wait for the el...

15 Feb at 08:1

Difference between DispatchQueue.main.async and DispatchQueue.main.sync

Difference between DispatchQueue.main.async and DispatchQueue.main.sync I have been using `DispatchQueue.main.async` for a long time to perform UI related operations.

 Swift provides both `DispatchQu...

multiprocessing.Pool: When to use apply, apply_async or map?

multiprocessing.Pool: When to use apply, apply_async or map? I have not seen clear examples with use-cases for [Pool.apply](https://docs.python.org/2/library/multiprocessing.html#multiprocessing.pool....

What's the difference between Thread start() and Runnable run()

What's the difference between Thread start() and Runnable run() Say we have these two Runnables: Then what's the difference between this:

support for servicestack ormlite timestamp

support for servicestack ormlite timestamp is it possible to use SqlServer Timestamp for optimistic concurency in servicestack-ormlite? currently if I am using it ormlite is trying to update it, I gue...

Concurrent Dictionary Correct Usage

Concurrent Dictionary Correct Usage Am I right in thinking this is the correct use of a Concurrent Dictionary ``` private ConcurrentDictionary myDic = new ConcurrentDictionary(); //Main thread at prog...

Return collection as read-only

Return collection as read-only I have an object in a multi-threaded environment that maintains a collection of information, e.g.: I currently have `return data;` wrapped by a `ReaderWriterLockSlim` to...