are static functions threadsafe?

Ask a Question related to ASP.NET General, Design and Development.

  1. #1

    Default 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?


    David Guest

  2. Similar Questions and Discussions

    1. #40765 [NEW]: calling backtrace inside nested static class functions causes segfault
      From: ndroege at bimp dot de Operating system: linux debian PHP version: 5.2.1 PHP Bug Type: Reproducible crash Bug...
    2. #39713 [NEW]: Static variables defined in static methods duplicated in derived classes
      From: paul at digitalbacon dot us Operating system: Linux, Mac OS X 10.4, Windows XP PHP version: 5.2.0 PHP Bug Type: ...
    3. #38783 [NEW]: Call to non-static as static E_STRICT thrown when error reporting set to E_ALL
      From: dmb27 at cornell dot edu Operating system: Redhat AS 4 PHP version: 5.1.6 PHP Bug Type: Class/Object related Bug...
    4. [RFC] Thread::MappedQueue - threadsafe queue with mapped responses
      Concept for a new Thread module, looking for feedback, or if I've overlooked an existing module that already does this, or if there's a better name...
    5. PHP5 and static functions/vars
      Hi, I need to add a string to a class var, but it doesn´t work though I read it is a new feature in PHP5. This is my code: class Huh{ static...
  3. #2

    Default 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.12144$j%4.512912@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?
    >
    >

    Marina Guest

  4. #3

    Default 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@hotmail.com> wrote in message
    news:OUSR7HWVDHA.1744@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.
    >

    David Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139