1
2
3
4
5
6
7 package org.mule.util.concurrent;
8
9 import edu.emory.mathcs.backport.java.util.concurrent.Executor;
10
11
12 public abstract class AbstractSynchronizedVariable implements Executor
13 {
14
15 protected final Object lock;
16
17 public AbstractSynchronizedVariable()
18 {
19 super();
20 lock = this;
21 }
22
23 public AbstractSynchronizedVariable(Object lock)
24 {
25 super();
26 this.lock = lock;
27 }
28
29 public Object getLock()
30 {
31 return lock;
32 }
33
34 public void execute(Runnable command)
35 {
36 synchronized (lock)
37 {
38 command.run();
39 }
40 }
41
42 }