Watch, Follow, &
Connect with Us

For forums, blogs and more please visit our
Developer Tools Community.


Welcome, Guest
Guest Settings
Help

Thread: are variables defined in IWUserSession thread safe



Permlink Replies: 2 - Last Post: Mar 12, 2018 2:20 AM Last Post By: Alexandre Machado
David Novo

Posts: 40
Registered: 8/5/07
are variables defined in IWUserSession thread safe
Click to report abuse...   Click to reply to this thread Reply
  Posted: Mar 11, 2018 9:48 PM
Hello,
If I define my own variables inside IWUserSession, can i guarantee that they will only be accessed by one thread at a time, or do I have to protect access to every variable within the UserSession instance?
Dan Barclay

Posts: 889
Registered: 11/9/03
Re: are variables defined in IWUserSession thread safe
Click to report abuse...   Click to reply to this thread Reply
  Posted: Mar 11, 2018 10:29 PM   in response to: David Novo in response to: David Novo
David Novo wrote:
Hello,
If I define my own variables inside IWUserSession, can i guarantee that they will only be accessed by one thread at a time, or do I have to protect access to every variable within the UserSession instance?

I'd call them "thread friendly". They won't be accessed by anything except your own code. If you only access them from the session that owns the UserSession then you will not have thread problems.

If you decide to access the variables of one session from another session then you'll want to deal with collisions, but that kind of access is fairly rare.

What did you have in mind?

Dan
Alexandre Machado

Posts: 1,754
Registered: 8/10/13
Re: are variables defined in IWUserSession thread safe
Click to report abuse...   Click to reply to this thread Reply
  Posted: Mar 12, 2018 2:20 AM   in response to: David Novo in response to: David Novo
David Novo wrote:
Hello,
If I define my own variables inside IWUserSession, can i guarantee that they will only be accessed by one thread at a time, or do I have to protect access to every variable within the UserSession instance?

Under normal circumstances they can only be accessed by a single thread, unless you create some very convoluted (and unusual) code to access it. I don't see any need for concurrent access protection in this case.
Legend
Helpful Answer (5 pts)
Correct Answer (10 pts)

Server Response from: ETNAJIVE02