are static functions threadsafe?

D

David

I have a static method in the dll that looks like this

public static int myStaticFunction(int input){
}

My question is, should I use a mutex inside the function to ensure that the
function is threadsafe? This is used for ASP.NET. I am asking this
question without knowing how IIS works as a multi-threaded application.
Does each websession get a thread? If so, if two users are calling the
static function at the same time, do they
- act as two seperate threads?
- If so, are static functions threadsafe?
 
M

Marina

They are not thread safe, and you need to synchronize them.

There will be a separate thread for each user accessing the web server.
 
D

David

Thank you. My friend and I have been debating this. Is there some
documentation you could point me to?
 

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

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top