title: Java ScheduledFuture get List
body: <p>This code always returns me 10. I think that problem with receiving list of all features. I need to parse every feature and stop execution scheduler when variable limit will equals 5. How can I do this?</p>
  
  <pre><code>static int limit = 0;
  static final int testNum = 10;
  
  static ScheduledExecutorService scheduler;
  public static void main(String[] args) {
      scheduler = Executors
              .newScheduledThreadPool(5);
      ScheduledFuture&lt;Integer&gt; future = scheduler.schedule(new ScheduledPrinter(), 10, TimeUnit.SECONDS);
      try {
          while (true) {
              System.out.println(future.get());
              if(future.get() != testNum){
                  return;
              }
          }
      } catch (InterruptedException e) {
          e.printStackTrace();
      } catch (ExecutionException e) {
          e.printStackTrace();
      }
  }
  private static class ScheduledPrinter implements Callable&lt;Integer&gt; {
      public Integer call() throws Exception {
          limit++;
          if(limit==5) {
              scheduler.shutdown();
              return limit;
          }
          return testNum;
      }
  }
  </code></pre>