title: Java EOFException Server/Client TCP application
body: <p>I am running 2 threads in my applciation. One to check for incoming packets and one to process and send packets. They both do it on the SAME STREAM.</p>
  
  <p>Example for 1:</p>
  
  <pre><code>while (connection open) {
      in.readObject() instanceof ...
  }
  </code></pre>
  
  <p>Example for 2:</p>
  
  <pre><code>while (connection open) {
      processPacket(in)
  }
  </code></pre>
  
  <p>I'm pretty sure EOFException is when the threads try and use the stream at the same time. It's not a constant EOF but only like every 1 second I get an EOF the rest works fine. So that's why I suspect that they overlap and try to use the stream at the same time.</p>
  
  <p>If that is the problem, anyone know how do I synchronize them to do it after another while still keeping the current update speed and using two threads?</p>
  
  <p>I need two threads because the check for incoming waits in a line until a packet gets recived and I need the server to constantly send process and check for packets.</p>
  
  <p>How do I fix the EOFException?</p>