title: Java program hangs on joining a thread
body: <p>I'm making a simple chat program using sockets, and I have an ArrayList to store active objected classes with sockets and usernames for each connected client, and inside those classes it checks if the socket is still open, and calls for its self to be joined if it is not.</p>
  
  <p>Server file kick code:</p>
  
  <pre><code>public synchronized void kick(ClientThread client){
      try{
          output.printLine("kicking " + client.getUsername());
          clients.remove(client);
          output.printLine("removed " + client.getUsername());
      }catch(Exception e){
          e.printStackTrace();
      }
      output.printLine("kicked ");
  }
  </code></pre>
  
  <p>This is what is called by the client object if its socket is closed.</p>
  
  <p>clients being the ArrayList which stores the clients</p>
  
  <p>client being the class object which I want to join, the client object extends Thread</p>
  
  <pre><code>public void run(){
  
      while(true){
          try{
              Thread.sleep(10);
              if(isValid()){
                  /*bufferedReader = new BufferedReader(new InputStreamReader(socket.getInputStream()));
                  if(bufferedReader.ready()){
                      lastMsg = bufferedReader.readLine();
                      sendMessage("Hello");
                      bufferedReader.close();
                  }*/
              }else{
                  output.printLine(this.getUsername() + " connection closed");
                  break;
              }
          }catch(Exception e){
              e.printStackTrace();
          }
      }
  
      server.kick(this);
      try {
          join();
      } catch (InterruptedException e) {
          e.printStackTrace();
      }
      output.printLine("joined " + getUsername());
  }
  </code></pre>
  
  <p>This is the run function from the client object, at the bottom is the code which is run when the socket is not connected, it breaks from the loop and should join its self, however it hangs on joining its self. The client is removed from the ArrayList properly but no matter what i do i cannot get the thread to join.</p>