6 Replies Latest reply on May 2, 2014 9:43 AM by Sueleyman Vurucu

    JSR 236 Concurrency API - Kill threads with redeployment

    Sueleyman Vurucu Expert

      Hi,

       

      lets assume we have a simple lonrunning thread like shown below.

       

      ...
      
      run(){
      while(true){
           doJob();
      }
      ....
      
      
      
      }

       

      How can I kill this thread after a redeployment?

       

      I try this. But after a redeployment the thread is still alive.

       

      @Resource
      ManagedThreadFactory mtf ;

       

      @Resource
      ManagedExecutorService extExecutorService;

       

       

      @Test
      public void test() throws InterruptedException {
      //   Thread thread1 = mtf.newThread();
      Thread managedThread = mtf.newThread(new MyThread("MTF"));
      extExecutorService.submit(managedThread) ;
      Thread.sleep(5000);

       

      }