synchronization - Avoiding multiple lock attempts java -


i have following method:

public foo bar(string id) {     lock locallock = lockutil.lock(id);     try {         something;         return foo;     } {         lock.unlock();     } } 

i need override method take in parameter.

public foo bar(string id, integer index) {     lock locallock = lockutil.lock(id);     try {         index;     } {         lock.unlock();     }      return bar(id); } 

my question is, how can achieve without obtaining locks twice (in case second method called)? don't want change signature of original method, since mean making changes @ 10 different places in system. i'd appreciate ideas. can give more clarification regarding question, if required. thanks.


Comments

Popular posts from this blog

c++ - QTextObjectInterface with Qml TextEdit (QQuickTextEdit) -

javascript - angular ng-required radio button not toggling required off in firefox 33, OK in chrome -

xcode - Swift Playground - Files are not readable -