title: How to hit 1000 endpoints using multi threading in groovy?
body: <p>I have a requirement to hit <strong>endpoints more than 1000 times</strong> to fetch some data from website. So i read some tutorials to use <strong>Multi Threading</strong> to achieving it. But at a time i want to use only 13 threads <strong>on same method</strong>.</p>
  
  <p>So basically i am using <strong>ExecutorService</strong> to run 13 threads at one time: </p>
  
  <pre><code>ExecutorService threadPool = Executors.newFixedThreadPool(13);
  for (int itLocation = 0; itLocation &lt; locationList.size(); itLocation++) {
    //some code like
    ScraperService obj = new ScraperService(threadName,url)
    threadPool.submit(obj);
  }
  threadPool.shutdown();
  </code></pre>
  
  <p>My Groovy Class named as <strong>ScraperService</strong> is <strong>implementing the Runnable interface</strong>.</p>
  
  <pre><code>@Override
          void run() {
              println("In run method...................")
              try {
                  Thread.sleep(5000);
                  someMethod()
              } catch (InterruptedException e) {
                  e.printStackTrace();
              }
          }
  </code></pre>
  
  <p><strong>Problem:</strong> </p>
  
  <p>My problem is that my <code>ExecutorService.submit(obj)</code> and <code>ExecutorService.execute(obj)</code> is not calling my run() method of Runnable interface.</p>
  
  <p><strong>In Groovy/Grails:</strong></p>
  
  <p>There is also a executor plugin <a href="http://plugins.grails.org/plugin/uberall/grails-executor" rel="nofollow noreferrer">Executor Plugin in grails</a> but i didn't found any appropriate example how to use it.</p>