class A extends Thread{
   Socket socket=null;
   public A(Socket socket){
     this.socket=socket;
   }
   public void run(){
    //socket.getInputStream();
    do your biz.
  }
}class Server extends Thread{
  public void run(){
    ServerSocket ssocket=....;
   
    while(ssocket!=null){
          try{
                Socket socket=ssocket.accept();
                new A(socket).start();
          }catch(.....){}
    }
  }}
//that's ok.