473,394 Members | 1,785 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

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 2898
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: Seenu | last post by:
Is it safe to create a static function in a multi threaded application ? As an example, I have a function that logs errors ,exceptions and some informational data public static void Log(....) {...
25
by: Sahil Malik [MVP] | last post by:
So here's a rather simple question. Say in an ASP.NET application, I wish to share common constants as static variables in global.asax (I know there's web.config bla bla .. but lets just say I...
3
by: Diffident | last post by:
Hello All, Following is a static method. Can you please tell me if this is threadsafe...why? If it is not threadsafe...why? Thank you. public static string...
9
by: Pohihihi | last post by:
What could be the possible reasons (technical/non technical) of not using lots of static functions or variables in a program keeping in mind that Framework by itself has tons of static functions and...
7
by: Jon Vaughan | last post by:
I have a piece of code that I want to run on a Pocket Pc, I have written a data class that will store the small amount of data that is required for the program. As this class will be used via a few...
3
by: David Veeneman | last post by:
Why do these questions always come up on Friday afternoon? I'm starting to use GoF singleton classes in my projects. Right off the bat, I've run into a surprise. I thought that a Singleton could...
3
by: Adam | last post by:
What happens if one thread is executing a static constructor and another thread starts. Does the second thread block until the first is done in the static constructor? I want to make sure all my...
12
by: chandu | last post by:
hello, i want to know usage of static methods in a class. is it advantageous or disadvantage to use more static methods in a class. thank u
17
by: fmassei | last post by:
Dear all, I'm trying to put some old code in a portable, cross-platform library and I'm facing a big problem: is there a standard, platform- independent way to write a reentrant function that...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.