This week's book giveaway is in the JavaScript forum.
We're giving away four copies of Svelte and Sapper in Action and have Mark Volkmann on-line!
See this thread for details.
Win a copy of Svelte and Sapper in Action this week in the JavaScript forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

static methods

 
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a static method used to retrive data from databases.
What problem could I face if there are concurrent users accessing the same method.
Please suggest performance issues related to static methods.
 
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You would only face problems with concurrent users IF the static method made use of static variables to hold user-specific objects such as a database connection. If all variables are either on the stack or held in user specific object instances, no problem will arise.
I know of no performance issues related to static methods - you should be worried about clarity of design, not minute differences in execution speed.
Bill
 
lekha phijo
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank u bill.
Thats right I guess I should concentrate on the code pattern.
 
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
HI Bill
Is it not true that at any given point of time, only one user can execute this method. Hence if there are maney concurrent users then all such calls would be queued and they would be executed serailly. is it not a performance issue?
Regards
Rajeev
 
William Brogden
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Is it not true that at any given point of time, only one user can execute this method.


You appear to be thinking about synchronized methods - a static method can be synchronized or not depending on the requirements.
If the static method has to use a static variable - such as a database connection - then of course you would have to synchronize access to it.
On the other hand, if each Thread calling the static method had its own database connection instance, there would be no problem.
Bill
    Bookmark Topic Watch Topic
  • New Topic