Thread Safe?

B

bob

I have an application that has 4 threads answering phone lines.
The threads make calls into a static class' functions.
Assume there will be 'concurrent' calls into any function.
Smallest function I could find is

public static void Play_Invalid_Option(AxVbocxLibrary.AxVBocx
Vbocx1,string sLangIndex)
{
string Phrase = sLangIndex + ".130";//invalid Option
Vbocx1.PlayPhrase(Phrase);
return;
}

Is this thread safe?
thanks
Bob
 
A

Alberto Poblacion

bob said:
I have an application that has 4 threads answering phone lines.
The threads make calls into a static class' functions.
Assume there will be 'concurrent' calls into any function.
Smallest function I could find is

public static void Play_Invalid_Option(AxVbocxLibrary.AxVBocx
Vbocx1,string sLangIndex)
{
string Phrase = sLangIndex + ".130";//invalid Option
Vbocx1.PlayPhrase(Phrase);
return;
}

Is this thread safe?

The function itself is thread-safe, since it doesn't use any resources
that might be shared by other threads. The local variable Phrase, as well as
the function parameters, are allocated on the stack, so each thread will
have its own copy.
HOWEVER, you want to be careful about the function that you are invoking
(Vbocx1.PlayPhrase) since that one *could* be unsafe, and we don't have any
information here about it.
 
B

bob

Hi Alberto,
Thanks for that.
The Vbocx1 object is definitely instantiated separately for each of
the four threads. It is a 3rd Party OCX which is supposed to be
threadsafe so should be OK.
regards
Bob
 

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