可能和thread有关,在thread还没有起来的时候你的这行代码就被执行了,所以会被block。如果写在其他方法中,thread已经初始化完毕,就不会block 整个程序。

解决方案 »

  1.   

    public void run() {
       try{
         socket = new Socket("localhost",1124);
         System.out.println("link_actionPerformed1!");
         ObjectInputStream ois = new ObjectInputStream(new  BufferedInputStream(socket.getInputStream()));
         System.out.println("link_actionPerformed2!");
         Thread.currentThread().sleep(5000);
         jTextArea1.append("系统消息:成功连接到服务器!\n");
         link.setEnabled(false);
       }catch(Exception e){
         jTextArea1.append(e.toString()+"\n");
       }
    已经有现成了,但是link_actionPerformed2!这句话显示不出来
      

  2.   

    该成这样试试:
    InputStream in = socket.getInputStream();
    ...
    System.out.println("link_actionPerformed2!");
    ...   //该做的一些操作。ObjectInputStream ois = new ...(in); //可能在此处还会block
      

  3.   

    可我是在socket中传递的vector型的对象,用你说的InputStream in = socket.getInputStream();
    能行吗?