File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Web Services and the fly likes Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Web Services
Bookmark ""Synchronized" method in Web Services" Watch ""Synchronized" method in Web Services" New topic
Author

"Synchronized" method in Web Services

Jayakrishnan R Nair
Greenhorn

Joined: Jan 24, 2008
Posts: 5

HI All,

I have a crazy question.

If I mark my web service method as "synchronized", will app server put all the web service requests in serial.

Means only one execution of the method takes place at a given time.

For normal threads or java application , that is the behaviour.


Theory is when you know something, but it doesn't work.<br />Practice is when something works, but you don't know why.<br />Programmers combine theory and practice: Nothing works and they don't know why.
Vinod K Singh
Ranch Hand

Joined: Sep 30, 2008
Posts: 198
May be or many not. App server may create many instances of service implementation class to serve the class. All depends on how web service is exposed and using which framework. By default JAX-WS RI creates a singleton instance of the implementation class in that scenario everything may go in serial.


My Blog
Gabriel Vince
Greenhorn

Joined: Feb 05, 2009
Posts: 24
you may still get into trouble later, when you put your application into more server nodes.. the application will not be serialized anyway.
IMHO maybe you should not serialize request on the level of WS (vinod is right, a server may use as many service instances as it wishes), but maybe on the backend (as a sigleton service class, database level, ..)..

g.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: "Synchronized" method in Web Services
 
Similar Threads
what's the use of synchronizing the service in servlet?
Can I call it in init method
About servlet's service() method synchronize
problem of thread safe
Web service method call behaviour?