Coverage Report - org.mule.util.concurrent.SynchronizedVariable
 
Classes in this File Line Coverage Branch Coverage Complexity
SynchronizedVariable
100%
11/11
N/A
1
 
 1  
 /*
 2  
  * $Id: SynchronizedVariable.java 7963 2007-08-21 08:53:15Z dirk.olmes $
 3  
  * --------------------------------------------------------------------------------------
 4  
  * Copyright (c) MuleSource, Inc.  All rights reserved.  http://www.mulesource.com
 5  
  *
 6  
  * The software in this package is published under the terms of the CPAL v1.0
 7  
  * license, a copy of which has been included with this distribution in the
 8  
  * LICENSE.txt file.
 9  
  */
 10  
 
 11  
 package org.mule.util.concurrent;
 12  
 
 13  
 import edu.emory.mathcs.backport.java.util.concurrent.Executor;
 14  
 
 15  
 // @ThreadSafe
 16  
 public abstract class SynchronizedVariable implements Executor
 17  
 {
 18  
     // @GuardedBy(itself)
 19  
     protected final Object lock;
 20  
 
 21  
     public SynchronizedVariable()
 22  
     {
 23  3224
         super();
 24  3224
         lock = this;
 25  3224
     }
 26  
 
 27  
     public SynchronizedVariable(Object lock)
 28  
     {
 29  2
         super();
 30  2
         this.lock = lock;
 31  2
     }
 32  
 
 33  
     public Object getLock()
 34  
     {
 35  4
         return lock;
 36  
     }
 37  
 
 38  
     public void execute(Runnable command)
 39  
     {
 40  8
         synchronized (lock)
 41  
         {
 42  8
             command.run();
 43  8
         }
 44  8
     }
 45  
 
 46  
 }