如下代码所示,在用stop结束线程时,stop被横线划掉了。而且报这个警告The method stop() from the type Thread is deprecated。会对线程的执行有影响吗?
tran_input = new Thread(new ActTranIn());
tran_input.start();
                /**执行SSLSocket接受数据的代码省略**/
tran_input.stop();         class ActTranIn implements Runnable {
         public void run() {
                          /**执行SSLSocket发送数据的代码省略**/
                        }
                }

解决方案 »

  1.   

    当SSLSocket发送数据的时候,会触发服务器端的发送代码。线程里的SSLSocket接收代码会开始接受服务器端传来的数据,并进行处理。
      

  2.   

    上面的注释写反了,应该是SSLSocket先发送,触发了服务器端的发送。然后线程开始接收服务器端发来的数据,接收到后停止线程。请参考下面的代码:
            tran_input = new Thread(new ActTranIn());
            tran_input.start();
                    /**执行SSLSocket发送数据的代码省略**/
            tran_input.stop();            class ActTranIn implements Runnable {
                    public void run() {
                              /**执行SSLSocket接受数据的代码省略**/
                            }
                    }
      

  3.   

    http://blog.csdn.net/DLite/article/details/4212915
      

  4.   

    我知道这个方法过时了,但是为啥别人写的代码里用stop就没报警呢?都是在一个工程里。我写的stop方法,被一条黑线划掉,鼠标移到stop上还有报警信息(The method stop() from the type Thread is deprecated。)。
    这样我的stop会不会不执行了?
      

  5.   

    那为啥同一个工程里,别人写的stop没有警告,我写的stop就警告呢?
      

  6.   

    Thread.stop()有bug的,有时候抛出运行时异常。所以不见意用这个方法。