R
R
Romanson2016-08-28 23:54:00
Delphi
Romanson, 2016-08-28 23:54:00

How to distribute a loop into separate execution parts of Delphi?

Hello dear geeks! Such question,
There is a cycle for i:=0 to z do begin. ...end.
In z I pass the number of lines from the listbox, in which, for example, 1000 lines.
With each line in this listbox I carry out the operation in a separate loop.
So, tell me how to implement so that cycles are made in the range 0-250, 250-500, 500-750, 750-1000. From this example, the cycle is divided into 4 ranges, which means you need to run 4 separate cycles for execution. 1000 lines is an example, you need a solution that would pass and let's say up to 1567 lines. Those. Divide the number of lines into separate parts of the execution.
Why am I? And why?
Let's say, for example, if you write in the
For i:=0 to 1000 do begin
G:=0
G:=g+1 loop
memo. String.Add(inttostr(g))...
Then one cycle will be processed in order.
And if the end of it is 1000000, then this business will take a long time.
And if you divide this case into parts, then it should be faster, what do you think and what are the examples?
Thank you in advance for your understanding and answers, I'm writing from the phone, do not scold me much!

Answer the question

In order to leave comments, you need to log in

2 answer(s)
V
vista1x, 2016-08-29
@vista1x

Four cycles will not be faster than one.
Alternatively, you can perform these actions in a separate thread.

R
Romanson, 2016-08-29
@Romanson

Do you mean create 4 threads? I mean, logically, if you run separate parts of this cycle at the same time, then it should be faster.
Or from 0 to 1000
Or 4 to 250, the execution time is less in theory, or am I not understanding something?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question