Because of the rules involving cache flushing and invalidation, a synchronized block in the Java language is generally more expensive than the critical section facilities offered by many platforms.
Even when a program contains only a single thread running on a single processor, a synchronized method call is still slower than an un-synchronized method call.
Updating your java
Scalability, as a property of systems, is generally difficult to define, and is often mix-used with "performance".
Yes, yes, scalability is closely related with performance, and its purpose is to get high performance.
However, most of popular Web 2.0 sites are built with script languages, and there are a lot of voices to doubt the scalability of Java Applications.
In this article, Wang Yu takes real world cases as examples to explain ways on how to scale Java applications based on his experiences on the laboratory projects, and at the same time, bring together practice, science, algorithms, frameworks, and experience on failed projects, to help readers on building high scalable Java applications.
Many software designers and developers take the functionality as the most important factor in a product while thinking of performance and scalability as add-on features and after-work actions.
Most of them believe that expensive hardware can close the gap of the performance issue. Last month, there was an urgent project in our laboratory.
I have been working in an internal laboratory for years.
This laboratory is always equipped with the latest big servers from our company and is free for our partners to test the performance of their products and solutions.
To observe the problems caused by the synchronized keyword, just send a QUIT signal to the JVM process, which gives you a thread dump.
If you have seen a lot of thread stacks just like the following in the thread dump file, which means that your system hits "Hot Lock" problem.
An example might be scaling out from one web server system to three.