Announcement

Collapse
No announcement yet.

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 - SLL Modules and PB Libraries

      http://www.masm32.com/board/index.php?board=69.0

      Comment


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

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

        Comment

        Working...
        X