title: Thread removing from arrayList and function inserting
body: <p>As title states I have problem with thread based structure. What I need to do is:</p>
  
  <ul>
  <li><p>one thread running in loop and checking if there exists something in list and if so then performing some operation on object and then removing it from list</p></li>
  <li><p>function which is called from 'outside' and adding new objects to this list.</p></li>
  </ul>
  
  <p>here is my approach:</p>
  
  <pre><code>public class Queue implements Runnable {
      private List&lt;X&gt; listOfObjects = new ArrayList&lt;X&gt;;
  
      public void addToList(X toAdd){
          listOfObject.add(toAdd);
      }
  
      public void run() {
          while(true){
              synchronized(listOfObjects){
              if(!listOfObjects.isEmpty()){
                  listOfObjects.get(0).doSth();
                  listOfObjects.remove(0);
              }
              }
          }
      }
  }
  </code></pre>
  
  <p>Is it proper approach? Should I also synchronize adding to this list?</p>