Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 943983
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T22:31:13+00:00 2026-05-15T22:31:13+00:00

For the example below, will the lock be release before i++ is executed? In

  • 0

For the example below, will the lock be release before i++ is executed? In otherwords will the lock be released when a function is called inside a lock?

lock (lockerobject /*which is static*/)
{
   call2anotherFunction();
   i++;
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T22:31:13+00:00Added an answer on May 15, 2026 at 10:31 pm

    The lock will not be released until the lock block is exited. lock doesn’t know or care what code you execute inside the block.

    In fact, as a general rule, what happens inside a block is not known to what’s outside of it:

    if (condition)
    {
        // The if doesn't know what happens in here
    }
    

    or

    using (var reader = XmlReader.Create(url))
    {
        // using doesn't care what happens in here
        throw new Exception("Unless...");
    } // Dispose will be called on reader here
    

    But the Dispose will only be called because the block is exited, not just because a throw happens inside it.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In the example below what's the simplest addContent function that will put some content
Reproducible example below. I have a simulation loop, within which I occasionally have rows
In the example below, I have a model Proof which contains a foreign key
The link below will take you to my example. My question is... without changing
How will I drag my items out of #draggable div with overflow:auto? Example below.
The example below, is just an example, I know that I don't need an
this example below works when hover event is trigered and when its not, its
The example below shows the code I am using to test whether a user
JSFIDDLE EXAMPLE BELOW I want to make the following CSS layout and currently im
The example below is from a REST database driver on Python 2.7. In the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.