title: How to fix concurrent.ExecutionException Caused by: java.lang.UnsupportedOperationException
body: <p>I posted a question on about brute forcing<a href="https://codereview.stackexchange.com/questions/230610/brute-force-id-reversal-search/230622?noredirect=1#comment449625_230622">CodeReview</a>, and a good <a href="https://codereview.stackexchange.com/users/25834/reinderien">expert</a> helped me out by suggesting I should use multithreading to improve the speed of my program. The code he gave was good, improved the speed but was still slow for me, so I went to research more about multithreading and found good <a href="https://www.journaldev.com/1069/threadpoolexecutor-java-thread-pool-example-executorservice" rel="nofollow noreferrer">articles</a> and <a href="https://www.callicoder.com/java-executor-service-and-thread-pool-tutorial/" rel="nofollow noreferrer">examples</a>. I copied one example that I understood and made few changes to fit my need. The code works perfectly till I read deep about multithreading and came across invokeAny(), I tried to implement it and thus the beginning of my headache for some unknown reason it's giving me errors. I just want to be able to get the first task that find the resolved ID using invokeAny, since the program is fast now.</p>
  
  <pre><code>Exception in thread "main" java.util.concurrent.ExecutionException: java.lang.UnsupportedOperationException: Not supported yet.
  at java.base/java.util.concurrent.FutureTask.report(FutureTask.java:122)
  at java.base/java.util.concurrent.FutureTask.get(FutureTask.java:191)
  at java.base/java.util.concurrent.AbstractExecutorService.doInvokeAny(AbstractExecutorService.java:199)
  at java.base/java.util.concurrent.AbstractExecutorService.invokeAny(AbstractExecutorService.java:220)
  at pait.SiimpleeThreadPool.main(SiimpleeThreadPool.java:31)
  Caused by: java.lang.UnsupportedOperationException: Not supported yet.
  at pait.WorkerThread.call(WorkerThread.java:73)
  at pait.WorkerThread.call(WorkerThread.java:15)
  at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
  at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
  at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
  at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
  at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
  at java.base/java.lang.Thread.run(Thread.java:834)
  </code></pre>
  
  <p><p></p>
  
  <pre><code>import java.util.ArrayList;
  import java.util.List;
  import java.util.concurrent.Callable;
  import java.util.concurrent.ExecutionException;
  import java.util.concurrent.ExecutorService;
  import java.util.concurrent.Executors;
  import java.awt.Label;
  import java.util.Random;
  import java.util.concurrent.Callable;
  public class SimpleThreadPool {
  
      public static void main(String[] args) throws ExecutionException, InterruptedException {
          ExecutorService executor = Executors.newFixedThreadPool(3);
          int s = 135000000;
          int e = 200000000;
          List&lt;Callable&lt;String&gt;&gt; callList = new ArrayList&lt;&gt;();
          for (int i = 0; i &lt; 3; i++) {
              Callable worker = new WorkerThread("" + i, s, e);
              callList.add(worker);
              s = s + 15520000;
          }
          String result = executor.invokeAny(callList);
          System.out.println(result);
          executor.shutdown();
          while (!executor.isTerminated()) {
          }
          System.out.println("Finished all threads");
      }
  
  }
  </code></pre>
  
  <p><p></p>
  
  <pre><code>public class WorkerThread implements Callable {
  
      private final  String command;
      private final int start;
      private final int end;
      private final Label lb = new Label();
  
      public WorkerThread(String s, int start, int end) {
          this.command = s;
          this.start = start;
          this.end = end;
      }
  
      public void run() {
          processCommand(start, end);
  
      }
  
      private void processCommand(int start, int end) {
          for (int i = start; i &lt; end; i++) {
              Random rand= new Random(i);
              long pair = rand.nextInt();
              if (pair == 739619665) {
                  System.out.println(start + "     " + end + "        Executing Task inside : " + Thread.currentThread().getName());
                  System.out.println(i);
                  lb.setText("Stop");
                  break;
              }
          }
      }
  
      ;
  
      @Override
      public String call() throws Exception {
      throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
      }
  
      @Override
      public String toString() {
          return this.command;
      }
  
  }
  </code></pre>