Announcement

Collapse

Maintenance

The forum could be offline for 30-60 minutes in the very near future for maintenance (said 3pm Pacific). I was behind on getting this notice. I do apologize.
See more
See less

Threads and Local Variables

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Threads and Local Variables

    If I have two threads running the same function are local variables with the function private for each thread?
    Brent Boshart

  • #2
    Yes.

    ------------------
    Perfect Sync: Perfect Sync Development Tools
    Email: mailto:[email protected][email protected]</A>

    "Not my circus, not my monkeys."

    Comment


    • #3
      Brent,

      When you use a LOCAL variable, it is allocated in a section of memory called
      the stack. This allocation takes place as the function/sub is called and it
      is deleted when the function/sub is finished so it simply does not exist
      anywhere else when the function/sub is not running.

      If you need to have a value that is available across diferent functions, use
      a GLOBAL variable that can be "seen" from diferent aprts of your code.

      Regards,

      [email protected]

      ------------------
      hutch at movsd dot com
      The MASM Forum

      www.masm32.com

      Comment


      • #4
        Thanks. I just was not sure what happened when two threads ran the function simultaneously.

        ------------------
        Brent Boshart

        Comment

        Working...
        X