如题

解决方案 »

  1.   

    设置一个布尔变量running,初始化为false;
    在start()方法中,将running置为true;
    提供一个公用的方法halt(),将running变量置为false;
    在run()方法中使用类似的while循环:  public void run(){
          while(running)
          {
               /*线程要执行的代码*/}
      }stop()方法在jdk较新的版本中建议不在使用    
      

  2.   

    使用 Thread.interrupt()方法来跳出阻塞代码;建议楼主给出你的程序。。那样好分析些^-^
      

  3.   

    public class CalculateThread extends   Thread{
       private EntityDataRetrieveCondition conditions = null;   
       public CalculateThread(EntityDataRetrieveCondition conditions){
       this.conditions = conditions;  
        }

        public void run(){
         向后台发送计算请求     } 
        
    }CalculateThread calculation = null; 
    calculation = new CalculateThread(conditions); 
    try {
       calculation.suspend();
    //      ((ThreadPoolServiceImpl)this.getCommandContext().getContext().lookup("svc:threadpool")).cancelPending(calculation);
    //      calculation.stop();
    //      calculation.destroy();
    //      ((ThreadPoolServiceImpl)this.getCommandContext().getContext().lookup("svc:threadpool")).destroy();
    //      Thread.interrupted();
         System.out.println(calculation.isAlive());
         calculation.interrupt();
         System.out.println(calculation.isAlive());
    //      System.out.println(Thread.activeCount() + "=========");
                        
        
         System.gc();
         System.out.println(Thread.activeCount() + "=========");
    //       } catch (NamingException e) {
    //        FILELOGGER.info(this.getClass().toString() + " : " + e);
    // }
       return;
      

  4.   

    后台计算???不是多线程???  
    想结束的话,就调用 interrupt();