Jump to content
UBot Underground

Noob multi threading question...


Recommended Posts

Hi Guys,

I would like to clarify something regarding multi threading -

Suppose I am processing items from a list using multi threading - and I am calling the 'next list item' function from within a thread - then is there a chance that two or more threads may end up using the same list item?


Say if 2 threads execute in parallel -and call  the next list item function for the same list - could they end up using the same llist item?

If yes, then how do we prevent this  from occuring?

Thanks.

Link to post
Share on other sites
you do not use next list item command - loop with global parameter, incrementing it immediately after use.

Could you please explain a bit more what you mean? Some code example ?

Link to post
Share on other sites

here is logic flow:

loop while #pos <= list total (your list with data)

      get data from file

      increment #pos

 

make sure pos parameter is global so each thread will "see" it was incremented and will take next pos item

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