I am refactoring a legacy project and I have found a code that uses String
for synchronization (Actually it's a Cache implementation).
public void method (String key, ...) {
synchronized(key) {
....
}
}
There is only one block which synchronize on String object key
.
I am wondering which is the best way for fixing/Refactoring the code?
Any ideas?