Concurrent modification issue with Node children list
<p>I have an issue that probably has it's cause in the concurrent modification of a list, and I want to understand what exactly is happening in this case:</p>

<pre><code>List&lt;Node&gt; childrenUnmodifiable = shipCanvas.getChildrenUnmodifiable();
for (Node node : childrenUnmodifiable) {
    ...
</code></pre>

<p>The <code>shipCanvas</code> is of type <code>javafx.scene.layout.Pane</code>.
In the above case it may occur that I get a <code>java.util.NoSuchElementException</code> on the line of the for loop. Is my assumption correct that his happens because when creating the <code>childrenUnmodifiable</code> list the list was altered?
When I employ a defensive copy strategy:</p>

<pre><code>List&lt;Node&gt; childrenUnmodifiable = new ArrayList&lt;&gt;(shipCanvas.getChildren());
for (Node node : childrenUnmodifiable) {
    ...
</code></pre>

<p>I get a <code>java.util.ConcurrentModificationException</code> when creating the <code>childrenUnmodifiable</code>. 
What options are there to avoid this behaviour? It would be acceptable to retrieve an element from the list that is  actually no longer in there.
I can see two options:</p>

<ol>
<li>Lock all access to the children of <code>shipCanvas</code>.</li>
<li>Execute everything in a single thread.</li>
</ol>

<p>I am not happy with both options especially the second one, as that single thread would have to be the UI thread. So are there any other options I am missing?</p>