This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
The moose likes Servlets and the fly likes About servlet's service() method synchronize Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "About servlet Watch "About servlet New topic
Author

About servlet's service() method synchronize

Raj chiru
Ranch Hand

Joined: Aug 12, 2008
Posts: 141
Q: can we make the service() method synchronized?
Ankit Garg
Sheriff

Joined: Aug 03, 2008
Posts: 9293
    
  17

Yes you can...


SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61088
    
  66

But doing so would not be wise.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
sc ghosh
Greenhorn

Joined: Mar 16, 2009
Posts: 1
Yes you can do that...... but essentially you would spoil the advantage of servlets then............ it would mean that the servlet would fail to handle multiple client requests at the same time............. it would just be like implementing the SingleThread model.............. you should refrain from doing this................
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

"java ninja", please check your private messages.


JavaRanch FAQ HowToAskQuestionsOnJavaRanch
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: About servlet's service() method synchronize