Results 1 to 2 of 2

Thread: Is static method thread safe?

  1. #1
    Contributing Member
    Join Date
    Sep 2006
    Answers
    962

    Is static method thread safe?

    I have a static method that takes an integer and returns a mathematically processed result. Since this method is frequently used in a lot of places, I have placed it in a common class and declared it as static, accessing only local variables and not any static variables.

    I want to know whether this method is thread safe?

    ------------------------
    suresh


  2. #2
    Contributing Member
    Join Date
    Sep 2006
    Answers
    962

    Re: Is static method thread safe?

    Any method, static or not, that uses only local variables of primitive type is thread safe. If the method touches any objects, then it may or may not be thread safe, depending on whether those object are used by any other code.

    ---------------------
    suresh


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
About us
Applying for a job can be a stressful and frustrating experience, especially for someone who has never done it before. Considering that you are competing for the position with a at least a dozen other applicants, it is imperative that you thoroughly prepare for the job interview, in order to stand a good chance of getting hired. That's where GeekInterview can help.
Interact