Share data between threads
问题 I'm trying to implement an algorithm that should run in parallel using threads or tasks. The difficulty is that I want the threads/tasks to share their best results from time to time with all other threads. The basic idea is this: //Accessible from each thread IProducerConsumerCollection<MyObject> _bestObjects; //Executed in each thread DoSomeWork(int n){ MyObject localObject; for(var i = 0; i < n; i++){ //Do some calculations and store results in localObject if((i/n)%0.5 == 0) { //store