1. If I'm in a load balancing scenario (Apache Server + 3 Tomcats: Tomcat1, Tomcat2 and Tomcat3) and I have a synchronized method. How will the application execute this method for 2 simultaneous access? It will be transparent, even if the first request of the synchroned method is alocated to the Tomcat1 and the second request of the synchroned method is alocated to the Tomcat2, Will the synchronized execution be maintained?
2. When an user calls a synchronized method and it broken (ex.: a loop), and, the second user is trying to call the same synchronized method. What will happen in that case? Will the second user wait infinitely? If Yes, can I configure a timeout?
The Java synchronized code feature is only local to the JVM that the method is executed in. Other JVMs can be executing the same code, but they will be unaware of each other and therefore won't synchronize with each other. That doesn't normally matter, since the language-based synchronized feature is mostly about maintaining the integrity of data internal to the JVM.
When clustering, you may have other synchronization needs where you need inter-JVM synchronization. The mechanisms you use in this case depend on what you're trying to keep synchronized. One of the more common things is databases, and for that you normally use transactions and/or table or row locking. For general work requests, you might use a message queue system.
"privilege" comes from the Latin words for "private" and "law" (legal) and dates to feudal times. To "claim privilege" meant that you were above the laws that applied to the common people.
Heroic work plunger man. Please allow me to introduce you to this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop