Using Thread pool in Jenkins pipeline

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Using Thread pool in Jenkins pipeline

ramesh pasham
Anyone tried the ThreadPool in jenkins pipeline? it is not executing as expected ? Please advise.

import java.util.concurrent.*
class MyRunnable implements Runnable{
   Integer l
   MyRunnable(Integer l){
      this.l  = l
     
   }
   void run(){
   try{
    print l
     }
    catch(Exception e){
          print e
    }
  }
 
}
node{
    stage('stage1') {
        ExecutorService executor = Executors.newFixedThreadPool(6)
        mylist = 1..100
        try{  
            for(l in mylist){
                MyRunnable worker = new MyRunnable(l)
                executor.execute(worker)
        }
         }
        finally{
            executor.shutdown()
    }  
}
}
-Ramesh

--
You received this message because you are subscribed to the Google Groups "Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/CALEm6wTV_ScKAatBqapZz_-hhN%3DqFX_%2BAqw_qhWyOsUv7RgtGQ%40mail.gmail.com.