title: Java multi-threading issue
body: <p>I have an object which contains data, I am queuing an Action (interface with a method that can be executed) with this object (the action will use object's data inside its method), and the queued Actions are going to be executed from another thread.</p>
  
  <p>I'd like to lock the object after sending it to the action queue (so from my main thread).</p>
  
  <p>Because I don't want object's data being changed before the other thread has processed it through the action queue.</p>
  
  <p>And I'd like the object to be unlocked, once the action queue will be processed, from the other thread.</p>
  
  <p>Code illustration:</p>
  
  <pre><code>// THREAD 1
  final Object object = getObjectFromSomeWhere(); 
  
  // lock the object here
  
  concurrentActionQueue.add(new Action() {
          @Override
          public void execute() {
            // will be executed from THREAD 2
            // do something with object
  
            //unlock here once the data is processed
  
          }
  </code></pre>
  
  <p>You would say I could sent a copy of the object to the Action, but my object is containing very big data and copying is taking to much time so I can't.</p>
  
  <p>Is there a way to do this without hardcoding lock() and unlock() methods to my object ?</p>