Jump to content
UBot Underground

Little help with thread strategy pretty please!


Recommended Posts

I need multiple threads that perform the same exact loop. The only difference is that each loop needs its own unique variable names so that they do not interfere with each other. Took me 12 hours to figure out this problem by the way -.- I know that generally setting up multiple threads would be like this:

 

Loop #

thread

Loop#

 

Script

 

but, this duplicates it exactly and I don't have the ability to put variables in variable names to increment the id's by 1 each time. I really want to be able to give the user the ability to choose the amount of threads he/she would want running at once, but the only idea I can think of is letting them reopen the exe's and run multiple exe's.

 

Any ideas?

Link to post
Share on other sites

Hi.

 

Put the code you want to execute in a thread into a define command.

Then you start a new thread calling that define and sending the necessary variables to it:

 

 

 
set(#active threads, $plugin function("Threads Counter.dll", "threads counter", "reset"), "Global")
set list position(%userurl, 0)
loop($list total(%userurl)) {
    loop while($comparison($plugin function("Threads Counter.dll", "threads counter", "read"), ">=", 25)) {
        wait(0.5)
    }
    set(#active threads, $plugin function("Threads Counter.dll", "threads counter", "increment"), "Global")
    filterresults($next list item(%userurl))
}
 
 
define filterresults(#nextitem) {
    thread {
        comment("THREAD COMMANDS HERE")
        set(#active threads, $plugin function("Threads Counter.dll", "threads counter", "decrement"), "Global")
    }
}
 
Please let me know if something is unclear. Or post your code where you run into problems.
 
Dan
Link to post
Share on other sites

Thanks for the reply. I'm trying to copy paste your code into ubot to get a better visual, but every time I copy paste the code and switch to node view, I get "assertion failed". Then ubot closes.

 

Also, would this give each thread the same variables, but with unique names?

 

For example:

 

Thread 1

Set Variable

A1

Set Variable

B1

 

Thread 2

Set Variable

A2

Set Variable

B2

 

Thread 3

Set Variable

A3

Set Variable

B3

 

etc

 

The reason I need them to have different name is because some of the variables scrape the html for an ID that changes every time a thread loops and this ID is needed to perform the task that I'm trying to accomplish.

 

Also, could the global and local options help with this? I'm not totally sure how local and global works. Maybe if I do this

 

Loop [Variable #userdecidesthreads]

Thread

Loop[Variable #userdecidesloops]

 

Set all variables local

the rest of my script

 

 

Would making each variable local make them only respond in the thread that they are in?

edit: After researching this, the answer is no lol

 

So another question. If I define a function or command(still trying to understand the difference) with my script, and set all variables to local, then create the loop, thread, loop logic and in the loops call the command. Would each loop hold local variables since those variables are in a defined command? I'm using http sockets, so it's hard to test this.

Link to post
Share on other sites

Hi.

 

There was a little error in the code. I removed one line.

 

You also need the threads plugin:

http://www.ubotstudio.com/forum/index.php?/topic/15441-free-plugin-threads-counter-ubot-v4-threading-fixed/

 

And you definately should use Ubot Version4 for this. 

I haven't tested it with V5

 

Dan

Link to post
Share on other sites

Okay, so my strategy worked with an idea influenced by you! Thank you :)

 

This is what I did.

 

Lets say you want multiple threads with the same exact loop in it, but want your variables to work in their specific thread alone without having to have separate threads with renamed variables.

 

Define command[named command]

loop[number]

Script here(make sure to set all variables and/or lists to local)

 

Loop[Number]

thread

in new browser

[named command]

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...