Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. .NET (Core and Framework)
  4. Multithreading Local Variables

Multithreading Local Variables

Scheduled Pinned Locked Moved .NET (Core and Framework)
helpquestion
4 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    MikeMarq
    wrote on last edited by
    #1

    In a multithreading application I was wondering if I need to worry about 2 seperate threads overwriting each other's local variables. In other words if 2 seperate threads called the same function at the same time would the compiled program in essence create 2 sets of local variables, one for each thread, or is there a risk that they could overwrite each others data? Thanks for your help, Mike

    L A 2 Replies Last reply
    0
    • M MikeMarq

      In a multithreading application I was wondering if I need to worry about 2 seperate threads overwriting each other's local variables. In other words if 2 seperate threads called the same function at the same time would the compiled program in essence create 2 sets of local variables, one for each thread, or is there a risk that they could overwrite each others data? Thanks for your help, Mike

      L Offline
      L Offline
      Leslie Sanford
      wrote on last edited by
      #2

      MikeMarq wrote:

      if 2 seperate threads called the same function at the same time would the compiled program in essence create 2 sets of local variables, one for each thread

      Yes. For more on this, check out a discussion[^] I had with someone on the C# message board.

      M 1 Reply Last reply
      0
      • L Leslie Sanford

        MikeMarq wrote:

        if 2 seperate threads called the same function at the same time would the compiled program in essence create 2 sets of local variables, one for each thread

        Yes. For more on this, check out a discussion[^] I had with someone on the C# message board.

        M Offline
        M Offline
        MikeMarq
        wrote on last edited by
        #3

        Cool, thanks for the help.

        1 Reply Last reply
        0
        • M MikeMarq

          In a multithreading application I was wondering if I need to worry about 2 seperate threads overwriting each other's local variables. In other words if 2 seperate threads called the same function at the same time would the compiled program in essence create 2 sets of local variables, one for each thread, or is there a risk that they could overwrite each others data? Thanks for your help, Mike

          A Offline
          A Offline
          arcticbrew
          wrote on last edited by
          #4

          Read about synclock and monitor. They provide a mechanism that locks an object and blocks other threads from accessing it except the thread that created the lock. When the lock is released the blocked threads are allowed similar lock and access.

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups