title: ConcurrentLinkedQueue: NotSerializableException
body: <p>I need to serialize ConcurrentLinkedQueue.</p>
  
  <pre><code>public class Service implements Serializable { 
      private static Queue&lt;Message&gt; messages = new ConcurrentLinkedQueue&lt;&gt;(); 
  
      public class Serialize {
          public static Queue&lt;Message&gt; getMessages() 
          { 
              return messages; 
          } 
      }
  }
  </code></pre>
  
  <p>Trying:</p>
  
  <pre><code>FileOutputStream fos = new FileOutputStream("filename");
  ObjectOutputStream oos = new ObjectOutputStream(fos);
  
  oos.writeObject(Service.Serialize.getMessages());
  </code></pre>
  
  <p>Result:</p>
  
  <blockquote>
    <p>java.io.NotSerializableException: server.Service$1    at
    java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1184)
      at
    java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1548)
      at
    java.io.ObjectOutputStream.defaultWriteObject(ObjectOutputStream.java:441)
      at
    java.util.concurrent.ConcurrentSkipListMap.writeObject(ConcurrentSkipListMap.java:1430)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)  at
    sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
      at
    sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      at java.lang.reflect.Method.invoke(Method.java:497)     at
    java.io.ObjectStreamClass.invokeWriteObject(ObjectStreamClass.java:988)
      at
    java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1496)
      at
    java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1432)
      at
    java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1178)
      at
    java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1548)
      at
    java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1509)
      at
    java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1432)
      at
    java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1178)
      at
    java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:348)</p>
  </blockquote>
  
  <p>How to???</p>