title: Object not locked by thread before wait in Android app on Non Activity
body: <p>I am calling a method <code>CreateOne</code> from <code>Non-Activity</code> class and <code>CreateOne</code> method needs to return an <code>Object</code> after <code>Task</code> execution. So I have addded the below line after calling the Task.</p>
  
  <pre><code>task.wait();
  </code></pre>
  
  <p>But it is returning error like</p>
  
  <pre><code>object not locked by thread before wait()
  </code></pre>
  
  <p>Here is my full code:</p>
  
  <pre><code>public class MyStitchHelper
  {
      public Object CreateOne(Map&lt;String, Object&gt; map) throws InterruptedException
      {
          Object returnObject = null;
          Document mapDoc = new Document(map);
          ArrayList&lt;Document&gt; list = new ArrayList&lt;&gt;();
  
          list.add(mapDoc);
  
          Document itemsDocument = new Document("items", list);
          PipelineStage itemsStage = new PipelineStage("literal", "", itemsDocument);
          Document AuthDocument = new Document();
          AuthDocument.append("database","my_db");
          AuthDocument.append("collection", _collectionName);
          PipelineStage AuthStage = new PipelineStage("insert", "mongodb-atlas", AuthDocument);
  
  
          Task&lt;List&lt;Object&gt;&gt; task = _client.executePipeline(itemsStage, AuthStage);
  
          task.wait();
  
          if(task.isSuccessful())
          {
              Log.e("UserDAL", task.getResult().toString());
              returnObject = task.getResult();
          }
          else
          {
              Log.e("UserDAL", "Error Adding Collectionsss");
              task.addOnFailureListener(new OnFailureListener() {
              @Override
              public void onFailure(@NonNull Exception e) {
                  Log.e("UserDAL", "" + e.getMessage());
              }
              });
          }
  
          return returnObject;
      }
  }
  </code></pre>
  
  <p>Calling Method:</p>
  
  <pre><code>public void AddUser()
  {
      MyStitchHelper DBHelper = new MyStitchHelper();
  
      Map&lt;String, Object&gt; map = new HashMap&lt;&gt;();
  
          map.put(User.Columns.EMAIL,user.get_userName());
          map.put(User.Columns.PASSWORD, user.get_password());
          map.put(User.BaseColumns.CREATED_DATE, Calendar.getInstance().getTime());
  
          Document doc = (Document) DBHelper.CreateOne(map);
  }
  </code></pre>
  
  <p>First of all, whether the implementation is correct of what I am trying to do is just creating a new user and returning the Document Object after creation.</p>
  
  <p>And why the error throws?</p>
  
  <p>Any Ideas?</p>