Run multiple threads, and the first one to open the site makes all the others stop running. Help

  • Автор темы Автор темы cesario678
  • Дата начала Дата начала

cesario678

Client
Регистрация
10.03.2022
Сообщения
227
Реакции
13
Баллы
18
Is there a way to run the bot with multiple threads, like around 20 threads, and when the thread that enters the site first, it locks all the other threads so that only the one that opened the site first can be used?
 
you can write some line in a file and check if the line is there, if it's there then pause, one of the threads will be the fastest to write the line and all other threads will see the line already there so they won't continue
 
  • Спасибо
Реакции: cesario678
Seems like a job for 'global variables', you could create a variable 'inuse', it's value will be shared across different threads.
Default value should be False
Before entering the page each thread must check if that global variable 'inuse' = false , if it is true- then wait 10s and check again.
When inuse = false - thread can enter the page, and set inuse= true, so other threads must wait, hope it makes sense.

111207
 
  • Спасибо
Реакции: cesario678

Кто просматривает тему: (Всего: 0, Пользователи: 0, Гости: 0)