469,625 Members | 1,089 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,625 developers. It's quick & easy.

are static functions threadsafe?

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?
Nov 17 '05 #1
2 2794
They are not thread safe, and you need to synchronize them.

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

"David" <no****@nospam.com> wrote in message
news:2v********************@twister.socal.rr.com.. .
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?

Nov 17 '05 #2
Thank you. My friend and I have been debating this. Is there some
documentation you could point me to?

"Marina" <mz*******@hotmail.com> wrote in message
news:OU**************@TK2MSFTNGP12.phx.gbl...
They are not thread safe, and you need to synchronize them.

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

Nov 17 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

25 posts views Thread by Sahil Malik [MVP] | last post: by
3 posts views Thread by Diffident | last post: by
9 posts views Thread by Pohihihi | last post: by
7 posts views Thread by Jon Vaughan | last post: by
3 posts views Thread by David Veeneman | last post: by
3 posts views Thread by Adam | last post: by
12 posts views Thread by chandu | last post: by
17 posts views Thread by fmassei | last post: by
reply views Thread by gheharukoh7 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.