title: Socket accept and multiple threads
body: <p>I have this issue I have no idea how to resolve and I'm at the brink of insanity. Programming, eh? :/</p>
  
  <p>Anyway, I have a server which has a thread to send users all the info it needs to (which needs to run constantly) and another thread that awaits new server connections. My problem is once <code>socket.accept()</code> is called, the other thread doesn't execute.</p>
  
  <p>So, to explain with code:</p>
  
  <pre><code>class Thread1 extends Thread {
  
  
    public void run() {
      while(true)
      {
        s=socket.accept();
      }
    }
  
  class Thread2 extends Thread {
  
    public void run() {
      //do stuff
      System.out.println("spam");
    }
  }
  
    public static void main(String[] args)
    {
      Thread1 t1 = new Thread1();
      t1.start();
  
      t1.Thread2 t2 = t1.new Thread2();
      t2.start();
    }
  }
  </code></pre>
  
  <p>Assume all other required member variables are present, no compile errors and connection functionality works fine. Just 'Thread2' executes only once.</p>
  
  <p>So my question is, how do I resolve this problem? </p>
  
  <p>Thanks in advance,</p>
  
  <p>Tim.</p>