Problem description: two List<> Entities, by ID is due to the large amount of data, to compare step by step, according to a list of article number, to dynamically create multiple threads, each thread execution comparing 1000 rows of data, for example, this cycle is how, you great god help help
CodePudding user response:
System. Threading. The Tasks. The Parallel To split into several pieces, I pass a few, paging and practical method to obtain the data
CodePudding user response:
Parallel faster than a single thread also slow ah
CodePudding user response:
reference 1/f, Eva will hit soy sauce response: System. Threading. The Tasks. The Parallel Want to split into several pieces, I preach a few, then the actual method to get data to page Parallel faster than a single thread is slow CodePudding user response:
The comparison of what you said, is to point to what is style? CodePudding user response:
refer to 4th floor are nu month god reply: , you said is to point to what is style? compare two list<> Inside an element of equal The foreach (var item in listentity3) { If (listentity2. The Exists (P=& gt; The sufferings p. ID==item. The ID & amp; & P. outpatient number==item. Outpatient number & amp; & P. name==item. The name & amp; & P. total transaction cost==p. total transaction cost)) { Listentity1. Remove (item); } The else { Listentity4. Add (item); } } CodePudding user response:
reference 5 floor qq_41108274 reply: Quote: refer to 4th floor are nu month god reply: The comparison of what you said, is to point to what is style? compare two list<> Inside an element of equal The foreach (var item in listentity3) { If (listentity2. The Exists (P=& gt; The sufferings p. ID==item. The ID & amp; & P. outpatient number==item. Outpatient number & amp; & P. name==item. The name & amp; & P. total transaction cost==p. total transaction cost)) { Listentity1. Remove (item); } The else { Listentity4. Add (item); } } Parallel is not absolutely will be faster than single thread, Because a parallel has overhead, data comparison, the parallel may be faster than single thread, Here, you two list data about how many CodePudding user response:
reference 6 floor is anger god reply: Quote: refer to the fifth floor qq_41108274 reply: Quote: refer to 4th floor are nu month god reply: The comparison of what you said, is to point to what is style? compare two list<> Inside an element of equal The foreach (var item in listentity3) { If (listentity2. The Exists (P=& gt; The sufferings p. ID==item. The ID & amp; & P. outpatient number==item. Outpatient number & amp; & P. name==item. The name & amp; & P. total transaction cost==p. total transaction cost)) { Listentity1. Remove (item); } The else { Listentity4. Add (item); } } Parallel is not absolutely will be faster than single thread, Because a parallel has overhead, data comparison, the parallel may be faster than single thread, Here, you two list data about how many? reference 6 floor is anger god reply: Quote: refer to the fifth floor qq_41108274 reply: Quote: refer to 4th floor are nu month god reply: The comparison of what you said, is to point to what is style? compare two list<> Inside an element of equal The foreach (var item in listentity3) { If (listentity2. The Exists (P=& gt; The sufferings p. ID==item. The ID & amp; & P. outpatient number==item. Outpatient number & amp; & P. name==item. The name & amp; & P. total transaction cost==p. total transaction cost)) { Listentity1. Remove (item); } The else { Listentity4. Add (item); } } Parallel is not absolutely will be faster than single thread, Because a parallel has overhead, data comparison, the parallel may be faster than single thread, Here, you two list data about how many? Basically are tens of thousands of data, also have the similar, I have the test faster and parallel thread, now want to hurry up with loop to do this kind of method cycle only a part of the The foreach (var item in listnewsum) { IN. Listnew=item; Thread TH=new Thread (IN the Insert); TH. The Start (); } The second method did not perform data New Thread (()=& gt; { The foreach (var item in listnewsum) { IN. Listnew=item; The Parallel. Invoke (IN. Insert); } }). The Start (); CodePudding user response:
I am weak weak ask, why not in the database are compared, it is just a join statement, as long as the server is not bad, millions more quickly, CodePudding user response:
You can according to the size of the List, first into several group, such as 1000, a group of circulation, with the batch of parallel thread processing, Note List<. T> Is not thread safe, be careful with multithreading,