title: How to synchronize the ArrayList in my code without using Collections class?
body: <p>How can I rewrite my code without using concurrent collections?</p>
  <pre><code>public static void main(String[] args) {
  
  ArrayList&lt;Integer&gt; source = new ArrayList&lt;&gt;();
  
  for(int i = 0; i &lt; 5; i++) {
      source.add(i);
  }
  List&lt;Integer&gt; synchList = Collections.synchronizedList(new ArrayList&lt;&gt;());
  
       Runnable runnable = () -&gt; {synchList.addAll(source);}; 
  }
  </code></pre>