I have a very simple program counting the characters in a string. An integer `threadnum` sets the number of threads and divides the data by `threadnum` accordingly into chunks for each thread to process.

Each thread increments the values contained in a shared dictionary, building a character historgram.

```
private Dictionary<UInt32, int> dict = new Dictionary<UInt32, int>();

```

* In order to wait for all threads to finish and continue with the main process, I invoke `Thread.Join`
* Initially I had a local dictionary for each thread which get merged afterwards, but a shared dictionary worked fine, without locking.
* No references are locked in the method *BuildDictionary*, though locking the dictionary did not significantly impact thread-execution time.
* Each thread is timed, and the resulting dictionary compared.
* The dictionary content is the same regardless of a single or multiple threads - **as it should be**.
* Each thread takes a fraction determined by threadnum to complete - **as it should be**.

**Problem**:

The total time is roughly a multiple of `threadnum` , that is to say the **execution time increases** ? 

(Unfortunately I cannot run a C# Profiler at the moment. Additionally I would prefer C# 3 code compatibility. )

Others are likely struggling as well. It may be that the **VS 2010 express edition vshost** process stacks and schedules threads to be run sequentially?

Another MT-performance issue was posted recently posted [here as "Visual Studio C# 2010 Express Debug running Faster than Release"](https://stackoverflow.com/questions/12309080/visual-studio-c-sharp-2010-express-debug-running-faster-than-release):

**Code**:

```
public int threadnum = 8;
Thread[] threads = new Thread[threadnum];
Stopwatch stpwtch = new Stopwatch();
stpwtch.Start();
for (var threadidx = 0; threadidx < threadnum; threadidx++)
{
    threads[threadidx] = new Thread(BuildDictionary);
    threads[threadidx].Start(threadidx);
    threads[threadidx].Join(); //Blocks the calling thread, till thread completion
}
WriteLine("Total - time: {0} msec", stpwtch.ElapsedMilliseconds);

```

Can you help please?

**Update**:

It appears that the strange behavior of an almost linear **slowdown with increasing thread-number** is an **artifact** due to the numerous hooks of the IDE's Debugger. 

Running the process outside the developer environment, I actually do get a 30% speed increase on a 2 logical/physical core machine. During debugging I am already at the high end of CPU utilization, and hence I suspect it is wise to have some leeway during development through additional idle cores.

As initially, I let each thread compute on its own local data-chunk, which is locked and written back to a shared list and aggregated after all threads have finished.

**Conclusion**: 

Be heedful of the environment the process is running in.