czwartek, 8 października 2015

How to make active waiting in separate thread


final ScheduledExecutorService newScheduledThreadPool = Executors.newScheduledThreadPool(1);
newScheduledThreadPool.scheduleAtFixedRate(new Runnable() {

 @Override
 public void run() {
  boolean isExecutionDone = false;
  try {
                    isExecutionDone = checkIfExecutionIsDone();
  } finally {
   if (isExecutionDone) {
    newScheduledThreadPool.shutdown();
   }
  }

 }
}, 1, 1, TimeUnit.SECONDS);

Brak komentarzy:

Prześlij komentarz