• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Are Static methods Thread safe?

 
Ranch Hand
Posts: 79
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
author and iconoclast
Posts: 24207
46
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Ernest Friedman-Hill,

Thanks a lot
 
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Prasad ,

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

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

Waiting for your reply.
Thanks.
 
Ranch Hand
Posts: 1970
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic