Results 1 to 2 of 2
  1. #1
    mikeg1z is offline Member
    Join Date
    Nov 2007
    Posts
    1
    Rep Power
    0

    Question Local Variables for a static method - thread safe?

    Are they?

    Is the exact memory location used for a local variable?
    The method is indeed static so it's in the same memory location, I assume, but are the local variables as well? If they are placed on the stack then there is a different copy for every calling thread.

    Does anybody knows for sure?

    Thanks,
    -Michael

  2. #2
    henry_78 is offline Member
    Join Date
    Aug 2007
    Posts
    47
    Rep Power
    0

    Default

    Hi,
    To say if u variable is thread safe or not, it has to be a globale varaible(a class variable).
    When a variable is decleared in a method, if gets distroied when the method execution is terminated..it dosent matter if its static or not, the fact is its a locale variable.

Similar Threads

  1. Are Local variables thread safe ?
    By samson in forum Threads and Synchronization
    Replies: 6
    Last Post: 12-21-2010, 03:34 PM
  2. The safe way to stop a thread
    By Java Tip in forum java.lang
    Replies: 0
    Last Post: 04-09-2008, 07:31 PM
  3. Struts framework. Is this thread safe?
    By JavaAl2 in forum Web Frameworks
    Replies: 1
    Last Post: 01-17-2008, 04:01 AM
  4. Replies: 0
    Last Post: 11-10-2007, 05:47 PM
  5. Replies: 1
    Last Post: 08-07-2007, 06:05 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •