Re: [jgroups-dev] anyway to do unlock in another thread

hyliu <[email protected]> Sun, 5 May 2013 20:06:57 -0700 (PDT)
Newsgroups gmane.comp.java.javagroups.devel
Message-ID <[email protected]>
thanks Bela, 
suppose the original code should have fix the lock issue. here just put a
backdoor, in case it still remains undetected lock issue after goto on-line
enviroment. 

thanks!
-hyliu.

Bela Ban wrote
> This is a hack. I'd rather fix the original code which doesn't release 
> the lock, to release it in a finally clause. I consider not releasing a 
> lock a bug.
> 
> On 4/28/13 6:57 AM, hyliu wrote:
>> I find a way, I know it's ugly, but it seems no better choice.
>>
>> customize CENTRAL_LOCK, add a hack to let the new thread pretend the
>> original thread. code is below. I tested it works.
>>
>> public class OptimizedCENTRAL_LOCK extends CENTRAL_LOCK {
>>      public static ThreadLocal
> <Long>
>  threadId = new ThreadLocal
> <Long>
> ();
>>      @Override
>>      protected Owner getOwner() {
>>          Long hackId = threadId.get();
>>          if (hackId != null){
>>              return new Owner(local_addr, hackId);
>>          }
>>          return super.getOwner();
>>      }
>>
>>      public static void pretendThread(long originalThreadId){
>>          threadId.set(originalThreadId);
>>      }
>>
>>      public static void unpretendThread(){
>>          threadId.remove();
>>      }
>> }
>>
>> the jmx bean to cleanup lock is below:
>>      public boolean unLock(String lockName, long originalLockThreadId) {
>>          try {
>>              OptimizedCENTRAL_LOCK.pretendThread(originalLockThreadId);
>>              lockService_.getLock(lockName).unlock();
>>          } finally {
>>              OptimizedCENTRAL_LOCK.unpretendThread();
>>          }
>>          return true;
>>      }
>>
>> original lock thread id is can be get from LockService.printLocks()
>>
>> ...any side effect in this way?
> 
> 
> -- 
> Bela Ban, JGroups lead (http://www.jgroups.org)
> 
> ------------------------------------------------------------------------------
> Try New Relic Now & We'll Send You this Cool Shirt
> New Relic is the only SaaS-based application performance monitoring
> service 
> that delivers powerful full stack analytics. Optimize and monitor your
> browser, app, & servers with just a few lines of code. Try New Relic
> and get this awesome Nerd Life shirt! http://p.sf.net/sfu/newrelic_d2d_apr
> _______________________________________________
> Javagroups-development mailing list





--
View this message in context: http://jgroups.1086181.n5.nabble.com/anyway-to-do-unlock-in-another-thread-tp9574p9587.html
Sent from the JGroups - Dev mailing list archive at Nabble.com.

------------------------------------------------------------------------------
Introducing AppDynamics Lite, a free troubleshooting tool for Java/.NET
Get 100% visibility into your production application - at no cost.
Code-level diagnostics for performance bottlenecks with <2% overhead
Download for free and get started troubleshooting in minutes.
http://p.sf.net/sfu/appdyn_d2d_ap1
_______________________________________________
Javagroups-development mailing list