Synchronize(“Cache_Group”) part gets skipped , why is it so?

sychronized("Cache_Group")

First thing that comes to mind is that sychronizing on a string is useless.

sychronized locks access to a block based on the given reference not the value. Using a “String” defeats this purpose because strings are immutable and calling synchronized(“Cache_Group”) twice will construct 2 strings with 2 different references, allowing the second iteration to break the intended lock.

EDIT: @see ReentrantLock for better access control

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)