thread?

G

Guest

I find in the documentation the following

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.



Then, I go to the members documentation and I find public methods or
protected methods.

Am I to conclude that the public methods are thread safe and the protected
methods are not?
 
L

Larry Serflaten

I find in the documentation the following

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.

Then, I go to the members documentation and I find public methods or
protected methods.

Am I to conclude that the public methods are thread safe and the protected
methods are not?

Not from what you posted here. Taking the members of the String class
as an example, the first Shared member is a Public Field called Empty,
the next is a Public Method called Compare. Note the S-shaped icon
on those two items. That indicates a Shared member, which is what
your Thread Safety comment was referring to. All the other properties
and methods of the String class not marked with that S-shaped icon,
are not shared. (The String type is thread safe, however)

Now look at the File class, and note it has a statement like the one
you list above. All of its members are Public Shared members, so
all of its members are thread safe.

Next up, the Graphics class. It also has a statemement like yours above,
and when you look at its members, only a few Public Methods after FromHdc
are Shared.

So to summarize what your statement says:
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.

For thread safety, the member has to be Public, and it has to be Shared.
(Protected methods are not Public....)

HTH
LFS
 
G

Guest

Not from what you posted here. Taking the members of the String class
as an example, the first Shared member is a Public Field called Empty,
the next is a Public Method called Compare. Note the S-shaped icon
on those two items. That indicates a Shared member, which is what
your Thread Safety comment was referring to. All the other properties
and methods of the String class not marked with that S-shaped icon,
are not shared. (The String type is thread safe, however)

how do I know that the String type is safe?
 
L

Larry Serflaten

how do I know that the String type is safe?

A. Because its immutable (it can't be changed so anyone can read it at any time).
B. Because the docs say so.

LFS
 
D

dinny

how do I know that the String type is safe?
A. Because its immutable (it can't be changed so anyone can read it at any time).
B. Because the docs say so.

So with a class as a whole I will look at the documentation, wheras
with methods I know by the 'shared' keyword, i.e. 'shared' cannot
apply to keyword class only to keyword 'sub' or 'function'.

Thanks very much.
 

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