Sanjeev 46 Posted August 3, 2013 Report Share Posted August 3, 2013 Hello , I have some doubts related to multi threading-- could Some advanced user who understands multi threading well.. please take a look and let me know if my logic is correct or not?Thanks a lot.How do I save data from inside of a thread -in a multi threading scenario..?Below I have written down what I think should be the right way to go about saving data from inside of a thread which uses local list and variables to process data -Could you please tell me if my logic is correct or not?-------------------------------------------------------------------------------------------------------2 different ways -a] to save 'processed data' from 'inside of a function or command in a thread having [local] lists/variables -b] and also [optionally] , to load data on to a variable to be processed inside of a thread--------------------------------------------------------------------------------------------------------------method - 01---outside of the thread -1. create a new 'global scope' list - to load data, which will later be read inside of a thread.----add list to list(%global list, $list from text("one,two,three,four,five,six,seven,eight", ","), "Delete", "Global")----2.inside the thread -read from the global list -using - 'next list item' - but add the data to a local variable or list----thread { in new browser { set(#get data, $next list item(%global list), "Local") add item to list(%local list, $next list item(%global list), "Delete", "Local") } decrement(#threadsOpen)}----[process this data]also, if some data needs to be saved after the thread finishes - use 'add item to a list with global scope' - but read data from a local variable/local list .thread { in new browser { set(#get data, $next list item(%global list), "Local") add item to list(%local list, $next list item(%global list), "Delete", "Local") add item to list(%save list, "{#get data},{$list item(%local list, 0)}", "Delete", "Global") } decrement(#threadsOpen)}-----Method -02-------------outside of the thread -1. create a new 'global scope' list position variable - this will be seen by 'all' open threads -and will be incremented inside the thread - to 'get' the next list item inside the local -functions or commands.----set(#listpositionCTR, "-1", "Global")---2.inside the thread -we increment the global list position variable first.Then,create a local list and read from that local list -using - the 'global scope' list position variable -(i.e instead of using next list item , we use list item(a list position variable)to add the data to a local variable or local list--------Is the above correct? Quote Link to post Share on other sites
Sanjeev 46 Posted August 4, 2013 Author Report Share Posted August 4, 2013 140 views and not a single reply? Quote Link to post Share on other sites
LoWrIdErTJ - BotGuru 904 Posted August 4, 2013 Report Share Posted August 4, 2013 it would be better if you give a live example code your using to debug for you.. also have you take a look at the entire thread athttp://www.ubotstudio.com/forum/index.php?/topic/10042-new-v4-tutorial-multi-threading-example/ which also goes over local lists, and variables, and how they are tied to the defined command and held local to that defined command when used within a thread Quote Link to post Share on other sites
the_way 52 Posted August 19, 2013 Report Share Posted August 19, 2013 i would steer clear of using tables/lists where you can can, and use a database instead. Many issues are resolved by using one. As for the issue of locals and lists, i would just use them global, which they are by default, and name them according to the thread duty, thread_scraping_table1thread_clicking_table1 once you get the hang more of what you're doing then you can start to tweak your code and improve upon it, and add more local functions, but its tricky when you are starting off to get it all right. Quote Link to post Share on other sites
Sanjeev 46 Posted August 19, 2013 Author Report Share Posted August 19, 2013 i would just use them global, which they are by default, and name them according to the thread duty, I don't understand what you mean would you care to elaborate with some sample code? Thanks. 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.