Pete_UK 9 Posted August 31, 2014 Report Share Posted August 31, 2014 I decided to test out the thread command. When I run the script below it seems to work okay. Watching the Debug window show the #i variable is the same as the %zlist list.But, when I run script several times in quick succession I notice some time there is a discrepancy See the attached image. As you can see the code is very simple so there doesn't seem to be much room for error, but obviously I am doing something wrong, somewhere .... OR ... is it that the thread command isn't working right? clear list(%zlist) set(#i, 0, "Global") loop(20) { loop(5) { runMe(#i) increment(#i) } } define runMe(#counter) { thread { add item to list(%zlist, #counter, "Don\'t Delete", "Global") } } http://content.screencast.com/users/Pete_1/folders/Jing/media/051781f7-2279-4e87-9bad-9bfa7bc1eb6d/2014-08-31_1801.png http://screencast.com/t/XnitPGSGoh Quote Link to post Share on other sites
kev123 132 Posted August 31, 2014 Report Share Posted August 31, 2014 There is a issue with ubots lists (adding item) in the fact that there not thread safe use my free plugin large data instead. thanksKev Quote Link to post Share on other sites
Pete_UK 9 Posted August 31, 2014 Author Report Share Posted August 31, 2014 Thanks for the info Kev. I'll check it out. I've noticed similar issues when writing out to a file when not using lists too. set(#i, 0, "Global") loop(10) { loop(15) { runMe(#i) increment(#i) } } define runMe(#counter) { thread { set(#gotPage, "{#counter} - QWERTY ", "Local") append to file("{$special folder("Desktop")}\\thread.txt", #gotPage, "End") } } Is this down to the THREAD command not working correctly or something else? Was thinking may be down to the APPEND TO FILE command. If one thread is already appending to the file when another thread tries to write, what happens? Does it just fail with no error message? Thanks,Pete Quote Link to post Share on other sites
kev123 132 Posted August 31, 2014 Report Share Posted August 31, 2014 Thanks for the info Kev. I'll check it out. I've noticed similar issues when writing out to a file when not using lists too. set(#i, 0, "Global") loop(10) { loop(15) { runMe(#i) increment(#i) } } define runMe(#counter) { thread { set(#gotPage, "{#counter} - QWERTY ", "Local") append to file("{$special folder("Desktop")}\\thread.txt", #gotPage, "End") } } Is this down to the THREAD command not working correctly or something else? Was thinking may be down to the APPEND TO FILE command. If one thread is already appending to the file when another thread tries to write, what happens? Does it just fail with no error message? Thanks,Peteits down to two threads trying to write at the same time causing loss of data. I wouldn't recommend using the append to file from a thread. create the data first in say a list then save to file once all is complete 1 Quote Link to post Share on other sites
UBotDev 276 Posted August 31, 2014 Report Share Posted August 31, 2014 Also writing data at such rate could be overloading your disk drive (especially HDD), since in your case you are writing to disk every few hundred millisecond (less than a second between writes)... so it's another reason to save data outside threads. 1 Quote Link to post Share on other sites
Pete_UK 9 Posted August 31, 2014 Author Report Share Posted August 31, 2014 Yep, I figured it must have been something to do with the append. That's actually what got me to try a list and watch in debug mode. From one issue to another So for this example do you recommend saving the data to a Large List (your plugin Kev) while in a thread and then processing the data once all threads are complete? I take it there shouldn't be any problem writing to the same list in multiple threads at the same time? Quote Link to post Share on other sites
kev123 132 Posted August 31, 2014 Report Share Posted August 31, 2014 Yep, I figured it must have been something to do with the append. That's actually what got me to try a list and watch in debug mode. From one issue to another So for this example do you recommend saving the data to a Large List (your plugin Kev) while in a thread and then processing the data once all threads are complete? I take it there shouldn't be any problem writing to the same list in multiple threads at the same time?yes do that, no the lists in the large data plugin are designed to be able to be written to from threads so shouldn't be any issues 1 Quote Link to post Share on other sites
Pete_UK 9 Posted August 31, 2014 Author Report Share Posted August 31, 2014 Thanks Kev. 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.