Denethor 1 Posted July 25, 2018 Report Share Posted July 25, 2018 (edited) Is there anyway to detect that all threads have finished before the main script continues?I have a script that spawns 21 threads, two at a time, with a minute pause between each set of two (just so everything isn't launching at once). loop while($table cell(&NEW,#a,0) != "") { loop(2) { MyLogin($table cell(&NEW,#a,0), $table cell(&NEW,#a,1), $table cell(&NEW,#a,2), $table cell(&NEW,#a,3), $table cell(&NEW,#a,4), $table cell(&NEW,#a,7)) increment(#a) } wait(60) }The problem I have is some threads take longer to complete than others and during testing I've seen the script start to move on to the next step in the process before all the threads had finished. Which is an issue because the next step needs data that is being retrieved from the threaded part. Edited July 25, 2018 by Denethor Quote Link to post Share on other sites
Denethor 1 Posted July 25, 2018 Author Report Share Posted July 25, 2018 I added a variable to the script and track it myself, but it seems there should be a way in Ubot to track this.It increments the variable in the loop that spawns the thread and then the last line of the defined thread is to decrement that same variable.Then I added a new loop in my code that just waits until the variable =0 before continuing on.Crude, but it works Quote Link to post Share on other sites
HelloInsomnia 1103 Posted July 25, 2018 Report Share Posted July 25, 2018 I added a variable to the script and track it myself, but it seems there should be a way in Ubot to track this.It increments the variable in the loop that spawns the thread and then the last line of the defined thread is to decrement that same variable.Then I added a new loop in my code that just waits until the variable =0 before continuing on.Crude, but it works This is the way to do it - at least for now that is. Quote Link to post Share on other sites
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.