Question about threads?

F

Fekkai

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
 
G

Guest

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

Guest

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?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top