title: How to deserialize synchronizedMap and synchronizedList?
body: <p>This is probably just a question of syntax (and my inability to find it ;)</p>
  
  <p>Here's the collections to be (de)serialized:</p>
  
  <pre><code>private Map&lt;String, Terminal&gt; terminals = Collections.synchronizedMap(new HashMap&lt;String, Terminal&gt;());
  private List&lt;Host&gt; hosts = Collections.synchronizedList(new ArrayList&lt;Host&gt;());
  </code></pre>
  
  <p>Here goes serialization:</p>
  
  <pre><code>ObjectOutputStream out = new ObjectOutputStream(new FileOutputStream("blah.dmp"));
  out.writeObject(synchronizedMap);
  out.writeObject(synchronizedList);
  </code></pre>
  
  <p>and now de-serializing, this throws a ClassCastException (obviously):</p>
  
  <pre><code>terminals = (HashMap&lt;String, Terminal&gt;) in.readObject();
  hosts = (ArrayList&lt;Hosts&gt;) in.readObject();
  </code></pre>
  
  <p>but the following won't compile (as well as manyyyyy other variations i've tried):</p>
  
  <pre><code>terminals = (Collections.synchronizedMap(new HashMap&lt;String, Terminal&gt;())) in.readObject();
  hosts = (Collections.synchronizedList(new ArrayList&lt;Host&gt;())) in.readObject();
  </code></pre>