again, question in parallel programming. Need clue??
I am having some piece of code that I want to execute parallel. I used parallel Linq, Task, and Parallel foreach. But all what they do, they runs threads on that peice of code parallel. 

This solves the parallel programming, but not the security of code. I mean I am adding some Items to list in that code, but items not added in atomic manner. One thread adds some itmes n between another one adds, again something somthing...

I want a clue that how I runs that code parallel but separate.

T1----- takes code and execute

same time 

T2-----takes code and execute
.
.
.
.
.


If I apply any locks on code then it won't call as parallel programming. Give any clue or hint. or tell me if I am wrong.

Thanks
again, question in parallel programming. Need clue??
===

I am having some piece of code that I want to execute parallel. I used parallel Linq, Task, and Parallel foreach. But all what they do, they runs threads on that peice of code parallel. 

This solves the parallel programming, but not the security of code. I mean I am adding some Items to list in that code, but items not added in atomic manner. One thread adds some itmes n between another one adds, again something somthing...

I want a clue that how I runs that code parallel but separate.

T1----- takes code and execute

same time 

T2-----takes code and execute
.
.
.
.
.


If I apply any locks on code then it won't call as parallel programming. Give any clue or hint. or tell me if I am wrong.

Thanks