Static methods and call stack in IIS / asp.net

The theoretical question. If you have 100 separate requests that go to the aspx webpage, which calls the static method below.

    public static GeocodeResult GeocodeQuery(string query)
    {
        int train, tube, dlr = 0;

        // manipulate these ints
        if (train)
        {
            // do something important
        }

    }

Does each request have a separate call stack?

If so - Does this call to the static method call these separate call stacks?

If so - Consequently, are these ints threads safe? i.e. 100 requests, 100 call frames, 300 tf.

Greetings

+3
source share
3 answers

, . , , , dir, .

, - , .

+6

, , , .

+1

, , - . .

, , .

. , .

, . , , . , . , :

private static int _balance;
private static void ThreadSafetyIssues()
{
    // Not thread  safe
    int temp = _balance;
    temp ++;
    _balance = temp;

    // Not thread safe
    temp = (int) HttpContext.Current.Session["balance"];
    temp ++;
    HttpContext.Current.Session["balance"] = temp;
}

HttpContext.Current . , , Session. -, _balance .

+1

Source: https://habr.com/ru/post/1719716/


All Articles