By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,375 Members | 1,095 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,375 IT Pros & Developers. It's quick & easy.

Question about threads?

P: n/a
I have a question about threads:
In the TCPClient help page I find the following explanation

"Thread Safety
Any public static (Shared in Visual Basic) members of this type are
safe for multithreaded operations. Any instance members are not
guaranteed to be thread safe."

What does it mean, I need an example of something that is not safe.

Tia
Nov 21 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
By members, it means methods. i.e. if you intend to call the same method of
the same *object* from two threads, you need to provide synchronisation. If
you only intend to call two static methods of the same *type* from different
threads, then you probably won't need to provide synchronisation as all the
data will be largley stack based.

"Fekkai" wrote:
I have a question about threads:
In the TCPClient help page I find the following explanation

"Thread Safety
Any public static (Shared in Visual Basic) members of this type are
safe for multithreaded operations. Any instance members are not
guaranteed to be thread safe."

What does it mean, I need an example of something that is not safe.

Tia

Nov 21 '05 #2

P: n/a
I'm not sure I agree with the last statement. Static methods can only access
static data members (right?), and the latter can not be implemented on a stack
because then they wouldn't be shared.
So, it must be that the class implementor knows that the static data members
are accessed using a monitor or some other mechanism that ensures thread
safety, no?

"Bonj" wrote:
By members, it means methods. i.e. if you intend to call the same method of
the same *object* from two threads, you need to provide synchronisation. If
you only intend to call two static methods of the same *type* from different
threads, then you probably won't need to provide synchronisation as all the
data will be largley stack based.

"Fekkai" wrote:
I have a question about threads:
In the TCPClient help page I find the following explanation

"Thread Safety
Any public static (Shared in Visual Basic) members of this type are
safe for multithreaded operations. Any instance members are not
guaranteed to be thread safe."

What does it mean, I need an example of something that is not safe.

Tia

Nov 21 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.