• Post Reply Bookmark Topic Watch Topic
  • New Topic

Are Static methods Thread safe?

 
prasad agarwal
Ranch Hand
Posts: 79
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi everybody,..

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?

Really appreciate your help on this..
Thanks
 
Ernest Friedman-Hill
author and iconoclast
Sheriff
Posts: 24213
35
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
prasad agarwal
Ranch Hand
Posts: 79
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Ernest Friedman-Hill,

Thanks a lot
 
Jesu Mani
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Prasad ,

Could you provide some information on accessing Exchange Server?
Refer this:

http://www.coderanch.com/t/271720/java/java/Retrieving-MS-Exchange-Server-Address

Waiting for your reply.
Thanks.
 
Peter Chase
Ranch Hand
Posts: 1970
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Jesu Mani:
Could you provide some information on accessing Exchange Server?


What on Earth is this doing in this thread? PatienceIsAVirtue, CarefullyChooseOneForum etc. etc.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!