S
S
smail_digital2017-11-05 21:31:18
In contact with
smail_digital, 2017-11-05 21:31:18

Why are some numbers skipped when trying to implement multithreading?

Explain, I wanted to multithread, but in the end it skips some ranges, skips, and even freezes from 1000 threads, + why different threads take the next digit one by one, but although it was planned to divide into several small ones
https://github.com/sdigi/VkDockSearch /blob/dev/VKD...

Answer the question

In order to leave comments, you need to log in

1 answer(s)
L
lam0x86, 2017-11-07
@lam0x86

for (int i = 0; i < taskCount; i++)
{
  Thread thread = new Thread(ParsingDocUserIdAync);
  p[1] = docStarId;
  p[2] += (int)offset;
  thread.Start(param);
  docStarId = p[2]+1;
  list.Add(thread);
}

You start threads by passing the same array as an argument, while changing it from the outside ( pand paramare the same object).
The call thread.Start(param)does not guarantee that the thread will be created and start executing immediately.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question