are static functions threadsafe?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • David

    #1

    are static functions threadsafe?

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

    public static int myStaticFunctio n(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?


  • Marina

    #2
    Re: are static functions threadsafe?

    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" <nospam@nospam. com> wrote in message
    news:2viVa.1214 4$j%4.512912@tw ister.socal.rr. com...[color=blue]
    > I have a static method in the dll that looks like this
    >
    > public static int myStaticFunctio n(int input){
    > }
    >
    > My question is, should I use a mutex inside the function to ensure that[/color]
    the[color=blue]
    > 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?
    >
    >[/color]


    Comment

    • David

      #3
      Re: are static functions threadsafe?

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

      "Marina" <mzlatkina@hotm ail.com> wrote in message
      news:OUSR7HWVDH A.1744@TK2MSFTN GP12.phx.gbl...[color=blue]
      > They are not thread safe, and you need to synchronize them.
      >
      > There will be a separate thread for each user accessing the web server.
      >[/color]


      Comment

      Working...