Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Method calls synchronization in Tomcat

 
Igor Zotov
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello everyone,
Does anyone know if I can use methods of an instance of a class for processing simultaneous requests? If there is only one instance of such a class per web application, then should all methods (called by servlet serving a request) be declared as synchronized, or synchronization will be done automatically by the servlet? I think it should be done automatically, but I am not sure.
Thanks for help!
 
Yong Chen
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
. Synchronization will NOT be done automatically by the servlet.
. Should all methods be declared as synchronized? It depends. If the method only uses local variables, no synchronization is needed. If the method accesses the instance/class variables, you usually should synchronize it. (Assuming you are not using SingleThreadModel)
[ August 21, 2003: Message edited by: Yong Chen ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic