RaviNada Kiran wrote:I know what static does mainly useful in Singleton classes .
Do not scan the article. Read the article.
I gone through your tutorial but could not get the concept.
RaviNada Kiran wrote:
If i make it as static then all the Threads will be acting on it . so don't do it .
RaviNada Kiran wrote:Thanks a lot sagar .
Bauke Scholtz wrote:That's a bad answer.
Bauke Scholtz wrote:
Java is multithreaded at any way, static or not. The only what controls threading is the 'synchronized' modifier, but that has completely nothing to do with this question.
what will be the pros and cons if i make the getConnection() static ??
Yes, generally, the the use of static methods is not recommended in web app, because its multi-threaded environment, any request may trying to call getConnection(), method asynchronously, which can cause a null connection object return
Bauke Scholtz wrote:How would it behave if you don't declare it static with regard to threading?
Bauke Scholtz wrote:The 'conn' is not a class variable, it is a threadlocal variable, so this problem won't occur.
Bauke Scholtz wrote: don't put words in other's mouth.
Sagar Rohankar wrote:
Now don't say "looks for what static means
This. Exactly this. This is what my therapist has been talking about. And now with a tiny ad:
Devious Experiments for a Truly Passive Greenhouse!https://www.kickstarter.com/projects/paulwheaton/greenhouse-1