no.
He is such a figure:
10 threads is responsible for according to the different conditions and different number, 15 thread responsible for buying,
10 flicking thread, sweep to the number in a TstringList public variable, buy, thread continuously from the variable, and then buy,
The question now is not fast enough!
No. I think the problem is: sweep to add into tstringlist, sweep speed is far greater than buy number, so, in the thread number from tstriglist buy # # is likely to have been bought by others, how can I take a number when collect the latest number? Sweep the number into a what type of variable, buy, thread according to the index order number, to get the latest number?
Or do you have any different opinions, is published
CodePudding user response:
Sweep speed is far greater than buy number numberThe buy you increase the number of threads to handle sweep to the number of...
May be due to sweep into the number, into the queue, in the long run is invalid, the waiting, is due to you not to be able to buy thread processing,
It simply, we sweep the number, don't have to queue, use the stack, so, after the priority scanning to the number of
Although can lead to the first sweep to number, will be for a longer time, even without treatment, (buy),
Have time for a long time, however, didn't meaning, basic direct throw away...
If the first sweep to first to buy, buy, thread is slow, will lead to the other people have been bought, you can only buy on here, can not buy, sold out...
CodePudding user response:
Method:1, a person can only take one at a time,
2, more than one person a desirable (conditions), to choose a number,
The code is completely different,
CodePudding user response:
Take number number obtained is likely to have been bought by others- others are the others? The others in the normal or software in the buy, with a different number?
That number should sweep to buy by a special thread to deal with,,,
CodePudding user response:
Your current design is not reasonable, well there are 25 threads access the same stringlist,1, consider thread safety problem, need to deal with the "lock" or critical section, look from your description, seems your code does not do this processing;
2, due to frequent the "lock" or critical section processing, there are a large number of system calls (user mode turn system need CPU) and reduce the overall program performance;
The thread priority consideration 3: esau, threads and buy, thread priority should be to distinguish?
Suggested that such design:
Number 1, and threading processing results are submitted to a "number submitted thread", this thread is responsible for writing TStringList;
No. 2, buy thread does not have direct access to TStringList number, and unified by "take thread" access TStringList take number, one by one to buy each thread issue number;
This is just a general process, inside still have a lot of details need to be considered, such as after take number whether need to remove, whether to need to determine the number, and so on, some details may affect performance,
CodePudding user response:
Multithreading, want to replace stringlist Tthreadlist