Sep 4, 2011

Benchmark on the synchronized statement - Java



Here is the result:



It is somewhat strange that ratio for 100,000 loops is bigger than for 1,000,000 loops. Maybe JVM optimizes something for us.

Now if you are going to design a system with the synchronized statement, please beware of the performance detriment.

If you do not call the synchronized more than 10,000 times (within a minute), I would just use the statement and go with a simpler architecture design.