Jump to content



Photo

Multithreading Tutorial: How To Multithread The Right Way


  • Please log in to reply
17 replies to this topic

#1 HelloInsomnia

HelloInsomnia

    Advanced Member

  • Moderators
  • 2478 posts
  • OS:Windows 10
  • Total Memory:More Than 9Gb
  • Framework:v4.5+, unsure
  • License:Developer Edition

Posted 11 October 2017 - 10:03 AM

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.

 


sc3jXAz.png


#2 Macster (UBotter Labs)

Macster (UBotter Labs)

    UBotter Staff

  • Fellow UBotter
  • PipPipPip
  • 620 posts
  • Locationwww.ubotter.com
  • OS:Windows 10
  • Total Memory:More Than 9Gb
  • Framework:v4.5+, unsure
  • License:Developer Edition

Posted 11 October 2017 - 10:07 AM

Awesome bud. Appreciated!

[UBotter Labs]

UBotter Labs UNLEASHED Licensing from €9 / Month

 

UbotLocker UNLEASHED Complete Protection from €97 includes 1 Year UBotter Labs Bronze Pack

 

Losers always talk about giving their best; Winners go home and take the prom queen.


#3 bestmacros

bestmacros

    Advanced Member

  • Fellow UBotter
  • PipPipPip
  • 342 posts
  • LocationIsrael
  • OS:Windows 10
  • Total Memory:More Than 9Gb
  • Framework:v4.5+, unsure
  • License:Developer Edition

Posted 11 October 2017 - 03:26 PM

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)


bestmacros1.jpg


#4 HelloInsomnia

HelloInsomnia

    Advanced Member

  • Moderators
  • 2478 posts
  • OS:Windows 10
  • Total Memory:More Than 9Gb
  • Framework:v4.5+, unsure
  • License:Developer Edition

Posted 11 October 2017 - 03:50 PM

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.


sc3jXAz.png


#5 bestmacros

bestmacros

    Advanced Member

  • Fellow UBotter
  • PipPipPip
  • 342 posts
  • LocationIsrael
  • OS:Windows 10
  • Total Memory:More Than 9Gb
  • Framework:v4.5+, unsure
  • License:Developer Edition

Posted 12 October 2017 - 02:36 AM

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.


bestmacros1.jpg


#6 HelloInsomnia

HelloInsomnia

    Advanced Member

  • Moderators
  • 2478 posts
  • OS:Windows 10
  • Total Memory:More Than 9Gb
  • Framework:v4.5+, unsure
  • License:Developer Edition

Posted 12 October 2017 - 09:09 AM

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)
    }
}

sc3jXAz.png


#7 bestmacros

bestmacros

    Advanced Member

  • Fellow UBotter
  • PipPipPip
  • 342 posts
  • LocationIsrael
  • OS:Windows 10
  • Total Memory:More Than 9Gb
  • Framework:v4.5+, unsure
  • License:Developer Edition

Posted 12 October 2017 - 10:05 AM

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


bestmacros1.jpg


#8 HelloInsomnia

HelloInsomnia

    Advanced Member

  • Moderators
  • 2478 posts
  • OS:Windows 10
  • Total Memory:More Than 9Gb
  • Framework:v4.5+, unsure
  • License:Developer Edition

Posted 12 October 2017 - 10:16 AM

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.


sc3jXAz.png


#9 bestmacros

bestmacros

    Advanced Member

  • Fellow UBotter
  • PipPipPip
  • 342 posts
  • LocationIsrael
  • OS:Windows 10
  • Total Memory:More Than 9Gb
  • Framework:v4.5+, unsure
  • License:Developer Edition

Posted 12 October 2017 - 11:02 AM

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.


bestmacros1.jpg


#10 HelloInsomnia

HelloInsomnia

    Advanced Member

  • Moderators
  • 2478 posts
  • OS:Windows 10
  • Total Memory:More Than 9Gb
  • Framework:v4.5+, unsure
  • License:Developer Edition

Posted 12 October 2017 - 11:14 AM

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.


sc3jXAz.png


#11 bestmacros

bestmacros

    Advanced Member

  • Fellow UBotter
  • PipPipPip
  • 342 posts
  • LocationIsrael
  • OS:Windows 10
  • Total Memory:More Than 9Gb
  • Framework:v4.5+, unsure
  • License:Developer Edition

Posted 12 October 2017 - 11:53 AM

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


bestmacros1.jpg


#12 luis carlos

luis carlos

    Advanced Member

  • Fellow UBotter
  • PipPipPip
  • 439 posts
  • OS:Windows 8
  • Total Memory:< 1Gb
  • Framework:v3.5
  • License:Developer Edition

Posted 12 October 2017 - 12:23 PM

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



#13 dbands

dbands

    Newbie

  • Fellow UBotter
  • Pip
  • 9 posts
  • OS:Windows 8
  • Total Memory:2Gb
  • Framework:v3.5 & v4.0
  • License:Developer Edition

Posted 12 October 2017 - 12:24 PM

Thank you for this.  Lots more would really be appreciated.



#14 HelloInsomnia

HelloInsomnia

    Advanced Member

  • Moderators
  • 2478 posts
  • OS:Windows 10
  • Total Memory:More Than 9Gb
  • Framework:v4.5+, unsure
  • License:Developer Edition

Posted 12 October 2017 - 02:01 PM

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.


sc3jXAz.png


#15 ptv001

ptv001

    Advanced Member

  • Fellow UBotter
  • PipPipPip
  • 79 posts
  • OS:Windows 8
  • Total Memory:8Gb
  • Framework:v4.0
  • License:Professional Edition

Posted 12 October 2017 - 06:27 PM

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



#16 dr. dre

dr. dre

    Advanced Member

  • Fellow UBotter
  • PipPipPip
  • 110 posts
  • LocationLos Angeles, CA
  • OS:Windows 8
  • Total Memory:4Gb
  • Framework:v3.5 & v4.0
  • License:Developer Edition

Posted 13 October 2017 - 01:31 AM

Multithreading to include proxies and parameters like you said would be a great video Nick...

#17 HelloInsomnia

HelloInsomnia

    Advanced Member

  • Moderators
  • 2478 posts
  • OS:Windows 10
  • Total Memory:More Than 9Gb
  • Framework:v4.5+, unsure
  • License:Developer Edition

Posted 15 October 2017 - 11:05 AM

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")
    }
}

sc3jXAz.png


#18 ptv001

ptv001

    Advanced Member

  • Fellow UBotter
  • PipPipPip
  • 79 posts
  • OS:Windows 8
  • Total Memory:8Gb
  • Framework:v4.0
  • License:Professional Edition

Posted 15 October 2017 - 10:51 PM

 

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.






0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users