Local variables in static method and thread safety

Viewed 13716

I have a question about variable scope.

For example:

class A {
    private static void test() {
        // do something with local variables
    }
}

Now I make two threads, and create one instance of A for each thread.

  1. When I call test() in each thread, can I guarantee that test() is thread safe?

  2. Where are the local varibles in test() stored? Each threads' stack? Heap space?

P.S. I know that static is totally pointless in this case. I found it in our legacy code; I just wanna make sure what I know!

3 Answers
Related