Jump to content
UBot Underground

Multithreading Tutorial: How To Multithread The Right Way


Recommended Posts

In this video I show you how to do multithreading the "right way" and by that I mean by not using thread spawn. Doing it this way gives you full control over the process and you know exactly what is going on in your code.

 

Quick note: You can skip to 18:50 for only the multithreading part but I highly recommend watching the entire video so you're not lost.

 

  • Like 8
Link to post
Share on other sites

good example, but there is little issue with your code - when you use loop parameter as number of accounts to create, it will not work as expected, as your code will create number of accounts equal to number of loops multiply by number of threads, meaning if you set 10 accounts to create in UI and set 10 threads to use - your code will actually create 10*10=100 accounts instead of 10.

To prevent this issue you need to limit the code to stop creating account if requested amount of accounts is already created (by using while loop or checking number of created accounts)

Link to post
Share on other sites

good example, but there is little issue with your code - when you use loop parameter as number of accounts to create, it will not work as expected, as your code will create number of accounts equal to number of loops multiply by number of threads, meaning if you set 10 accounts to create in UI and set 10 threads to use - your code will actually create 10*10=100 accounts instead of 10.

To prevent this issue you need to limit the code to stop creating account if requested amount of accounts is already created (by using while loop or checking number of created accounts)

 

That's not true, you can go 30 minutes into the video and see that I choose 5 accounts and select 2 threads and if you count the number of windows that open you will see that it's 5 in total and not 10.

 

And you can follow along with the video and try for yourself.

Link to post
Share on other sites

And what will happen if I set 3 accounts to create but set 10 threads to use?

Like I previously wrote your code does not count and control number of already created accounts.

 

Then 3 accounts will be made. Seriously you should follow along and make the code yourself I don't know why you think its doing these things but it won't. It uses the number of accounts to loop so if you say 3 accounts and 10 threads only 3 will be made. If you say 5 accounts and 3 threads then only 5 will be made.

 

Here is the code I made before the video that we remade, some things are named differently and it has a counter but its essentially the same thing, you can see for yourself, and I added 5 more threads so you can use 10 threads to see what happens:

ui drop down("Threads:","1,2,3,4,5,6,7,8,9,10",#threadCount)
ui text box("Accounts To Make",#loops)
ui stat monitor("Count:",#count)
set(#count,0,"Global")
set(#usedThreads,0,"Global")
clear list(%accounts)
clear list(%createdAccounts)
loop(#loops) {
    reset account("Any")
    add item to list(%accounts,"{$account data("Username")}:{$account data("Password")}","Don\'t Delete","Global")
}
loop(#loops) {
    loop while($comparison(#usedThreads,">= Greater than or equal to",#threadCount)) {
        wait(1)
    }
    increment(#usedThreads)
    clear list(%account)
    add list to list(%account,$list from text($next list item(%accounts),":"),"Delete","Global")
    CreateAccount($list item(%account,0), $list item(%account,1))
    wait(0.1)
}
loop while($comparison(#usedThreads,">",0)) {
    wait(1)
}
alert("Finished!")
define CreateAccount(#_username, #_password) {
    thread {
        in new browser {
            navigate("https://ubotstudio.com/site/playground-simple-form/","Wait")
            set(#_firstName,$spin("\{Andrew|Jose|Jason|Allie|Martha\}"),"Local")
            type text(<username field>,#_username,"Standard")
            type text(<password field>,#_password,"Standard")
            add item to list(%createdAccounts,"{#_username}:{#_password}","Don\'t Delete","Global")
        }
        increment(#count)
        decrement(#usedThreads)
    }
}
Link to post
Share on other sites

Ok, I see that you open the threads on-the-go and this will guarantee that account creation process will run exact amount of times, but still I don't understand why are you trying to deny obvious thing, which I already mention 2 times before - YOUR CODE DOES NOT count and control number of real created accounts, so if the process will fail you will create much less accounts even while you will run proper number of tries to create them.
In real life you would want to track total number of createdAccounts list which you don't do in your code at all.

Hope this will help you to understand...

Link to post
Share on other sites

Ok, I see that you open the threads on-the-go and this will guarantee that account creation process will run exact amount of times, but still I don't understand why are you trying to deny obvious thing, which I already mention 2 times before - YOUR CODE DOES NOT count and control number of real created accounts, so if the process will fail you will create much less accounts even while you will run proper number of tries to create them.

In real life if you would want to track total number of createdAccounts list which you don't do in your code at all.

Hope this will help you to understand...

 

Did you watch the video? The point of this is to teach multithreading, I say this in the video:

 

"In the real world your application would be much more complex than this. You would want to have built in logic to solve problems such as:

Info already taken such as username, or email

Invalid passwords

Failed captchas

And more

 

For now we want to keep it as simple as possible just to demonstrate how multi-threading works, so with that in mind we won’t be doing any more than this."

 

The point of this video isn't to make the worlds best account creator but to teach how to make something basic and then multithread it.

Link to post
Share on other sites

your code example is lacking major functionality which need to be handled on multi-threading level - it does not matter what your code does: creates accounts or send posts on Facebook - if you don't track and handle success results - your code will not achieve what it need to achieve.

Link to post
Share on other sites

your code example is lacking major functionality which need to be handled on multi-threading level - it does not matter what your code does: creates accounts or send posts on Facebook - if you don't track and handle success results - your code will not achieve what it need to achieve.

 

I am open to suggestions to improve the multithreaded part of the code if you think there is a better way to do it.

Link to post
Share on other sites
loop while($comparison($list total(%createdAccounts),"< Less than",#loops)) {
    loop while($comparison(#usedThreads,">= Greater than or equal to",#threadCount)) {
        wait(1)
    }
    reset account("Any")
    add item to list(%accounts,"{$account data("Username")}:{$account data("Password")}","Don\'t Delete","Global")
    increment(#usedThreads)
    clear list(%account)
    add list to list(%account,$list from text($next list item(%accounts),":"),"Delete","Global")
    CreateAccount($list item(%account,0), $list item(%account,1))
    wait(0.1)
}

Simple solution would be replacing loop with loop while and check for successfully created accounts - in this case the bot will work until it will create all needed number of accounts - obviously, since you generate input data before main loop you need to make sure you have enough generated data,so I've added the code which will add extra username/password data each loop - this way the bot will work until all needed accounts are created and it will always have enough generated data

  • Like 2
Link to post
Share on other sites

Thanks @HelloInsomnia, this works perfect and I finally understood the logic about the multithreading.   As you said in your video, each one can set more complex lines of code, based on their needs. :)

 

 

Luis Carlos

Link to post
Share on other sites
loop while($comparison($list total(%createdAccounts),"< Less than",#loops)) {
    loop while($comparison(#usedThreads,">= Greater than or equal to",#threadCount)) {
        wait(1)
    }
    reset account("Any")
    add item to list(%accounts,"{$account data("Username")}:{$account data("Password")}","Don\'t Delete","Global")
    increment(#usedThreads)
    clear list(%account)
    add list to list(%account,$list from text($next list item(%accounts),":"),"Delete","Global")
    CreateAccount($list item(%account,0), $list item(%account,1))
    wait(0.1)
}

Simple solution would be replacing loop with loop while and check for successfully created accounts - in this case the bot will work until it will create all needed number of accounts - obviously, since you generate input data before main loop you need to make sure you have enough generated data,so I've added the code which will add extra username/password data each loop - this way the bot will work until all needed accounts are created and it will always have enough generated data

 

 

Okay I see what you're saying and you're right that it's a better way to do it if you want to ensure the total number of accounts was created. I did list that as a requirement and so I can see where you're coming from. I really wanted to demonstrate the multithreading part that was the main point of the video, the requirements were to make it clear what we were going to do.

 

I will probably make a part 2 which talks more about other parts of multithreaing like including proxies, local variables and parameters and such. This was meant to show the basics and how to not use thread spawn. So I will make a note about this as well.

  • Like 2
Link to post
Share on other sites

Okay I see what you're saying and you're right that it's a better way to do it if you want to ensure the total number of accounts was created. I did list that as a requirement and so I can see where you're coming from. I really wanted to demonstrate the multithreading part that was the main point of the video, the requirements were to make it clear what we were going to do.

 

I will probably make a part 2 which talks more about other parts of multithreaing like including proxies, local variables and parameters and such. This was meant to show the basics and how to not use thread spawn. So I will make a note about this as well.

great, do you have any ubot sample code to show the multithreading with http post, thanks!!

Link to post
Share on other sites

great, do you have any ubot sample code to show the multithreading with http post, thanks!!

 

To keep things simple I will probably not use HTTP Post but you can use it, all you need to do is not use the browser commands so you don't need to use in new browser. Instead you can do something like this:

define YourCommandName {
    thread {
        comment("These should be local")
        set(#_get,$plugin function("HTTP post.dll", "$http get", "", "", "", "", ""),"Local")
        set(#_post,$plugin function("HTTP post.dll", "$http post", "", "", "", "", "", ""),"Local")
    }
}
Link to post
Share on other sites

 

To keep things simple I will probably not use HTTP Post but you can use it, all you need to do is not use the browser commands so you don't need to use in new browser. Instead you can do something like this:

define YourCommandName {
    thread {
        comment("These should be local")
        set(#_get,$plugin function("HTTP post.dll", "$http get", "", "", "", "", ""),"Local")
        set(#_post,$plugin function("HTTP post.dll", "$http post", "", "", "", "", "", ""),"Local")
    }
}

thank you, HelloInsomnia, will test it.

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...