Jump to content
UBot Underground

Accessibility of variables between the threads


Recommended Posts

I am doing a test script for my client. The four web fronts seem to generate canonicals in an intermittent/strange way. I need to see if this can be caused by stress, load or just because. Therefor I need to run several threads towards the server(s). When I am generating the stats I have a table and in this table I increase a variable for each new occasion where I test the server for the canonicals (whether canonicals are present or not in the generated web page), this explicitly means for each time a thread reads a page. When everything is ready, the idea is to save the table(s) into files that are partially identified by a thread ID (so there will be no conflict when accessing the file).

Well, the output in those files sucks and I just came to think of how variables are handled between threads.

 

I mean, a thread is a thread and not a process, huh!? So there is no process context that is unique to the thread or does the thread have its own set of variables, in my case e.g. the table. I mean let's say I have my row counter that I increment, I call it #rowOffset , every time I increment that in one thread, does that mean that another thread will see the incremented value or not? Will the table be accessible between threads? If so, is there some sort of synchronization functionality so that resources used by several threads are not messed up?

Link to post
Share on other sites

also keep in mind that

 

variables when global are set globally overwriting any previous set value.

 

When using them locally they are locally defined, and stored. So in fact they are not local to a thread but local to a defined command. create a defined command, and place your local variables in them, then call the defined command in the thread.

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