Jump to content
UBot Underground

Variables Inside Threads


Recommended Posts

Can somebody please shed some light onto UBot's stange looping / threading behavior?

 

When I run the following code, I get three alerts: 1, 2, and 3. (Strange that it's not 0,1, and 2, but that's besides the point).

 

set(#loopCounter,0,"Global")
loop(3) {
    thread {
        alert(#loopCounter)
    }
    increment(#loopCounter)
}

 

However, when I run the following code (I added "in new browser") my three alerts are all "3"

 

set(#loopCounter,0,"Global")
loop(3) {
    thread {
        in new browser {
            alert(#loopCounter)
        }
    }
    increment(#loopCounter)
}

 

I am trying to keep a variable inside each thread to keep track of that particular thread - but either UBot is not thread safe or I am doing something wrong. Any help greatly appreciated.

 

Thanks

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