How do I copy ArrayList<T> in java multi-threaded environment?
<p>In thread A, an <code>ArrayList</code> is created. It is managed from thread A only.
In thread B, I want to copy that to a new instance.</p>

<p>The requirement is that <code>copyList</code> should not fail and should return a consistent version of the list (= existed at some time at least during the  copying process). </p>

<p>My approach is this:</p>

<pre><code>public static &lt;T&gt; ArrayList&lt;T&gt; copyList(ArrayList&lt;? extends T&gt; list) {
    List&lt;? extends T&gt; unmodifiableList = Collections.unmodifiableList(list);
    return new ArrayList&lt;T&gt;(unmodifiableList);
}
</code></pre>

<p>Q1: Does that satisfy the requirements?</p>

<p>Q2: How can I do the same without <code>Collections.unmodifiableList</code> with proably iterators and try-catch blocks?</p>

<p><strong>UPD. That is an interview question I was asked a year ago. I understand this a bad idea to use non-thread-safe collections like ArrayList in multithreaded environment</strong></p>