这个好像没有public void run()方法啊!客户端创建实例化了10个客户端,每个客户端都向服务器发送请求,并接收服务器返回 的请求!
import java.io.*;
import java.net.*; 
class SocketThreadClient extends Thread
{
 public static int count = 0; public SocketThreadClient (InetAddress addr)
 {
  count++;
  BufferedReader in = null;
  PrintWriter out = null;
  Socket sk = null;
  try{
  
   sk = new Socket (addr, 8000);
   InputStreamReader isr;
   isr = new InputStreamReader (sk.getInputStream ());
   in = new BufferedReader (isr);
  
   out = new PrintWriter (new BufferedWriter(new OutputStreamWriter(sk.getOutputStream ())), true);
   
   System.out.println("count:"+count);
   out.println ("Hello");
   System.out.println (in.readLine ());
   out.println ("BYE");
   System.out.println (in.readLine ());  }
  catch (IOException e)
  {
   System.out.println (e.toString ());
  }
  finally
  {
   out.println("END");
   
   try
   {
    if (in != null)
     in.close ();
    if (out != null)
     out.close ();
    if (sk != null)
     sk.close ();
   }
   catch (IOException e)
   {
   }
  }
 }
}public class SocketClient{
  public static void main(String[] args) throws IOException,InterruptedException
  {
    InetAddress addr = InetAddress.getByName(null);
      for(int i=0;i<10;i++)
         new SocketThreadClient(addr);
      Thread.currentThread().sleep(1000);
  } 
}

解决方案 »

  1.   

    在eclips里 特意写了 用thread和runnable的线程,好像继承thread是不用重写run()方法,为什么呢!我的参考书上还特意写了 必须重写run方法,哎,
      

  2.   

    子线程类 extends Thread时是可以不用重写run()方法,但是当你 子线程类对象.start()方法就是调Thread类的run()方法了。而Thread类的run()方法不执行任何操作并返回。
    implements Runnable时是必须重写run()方法的。
      

  3.   

    继承thread不重写run()方法的话。那你这个线程就没啥用了。应该根据不同的需求重写run()方法。