0

I have the following 2 init methods that call doDataInit():

   public void sessionBegin(SessionEvent event)
         throws Exception {
      ....
      doDataInit();
   }

   public void init() {
      ...
      doDataInit();
   }

and the method:

private Future<WorkItems>
         doDataInit() {
      //do some stuff
      Callable<WorkItems> initData = getData();
      Future<WorkItems> result = EXECUTOR.submit(initData);
      return result;
   }

Now what I want to do is have a check inside the doDataInit method, that if true is going to sleep the task execution. Or otherwise said - I want to block the execution of the task until a certain condition is met and periodically check if the given condition is met. Once it is - continue execution.

What is the best (most effective) way to achive that in this scenario?

What I can currently think of is:

  • sleep the thread - uneffective
  • somehow block the callable
  • block the Executor
  • have a for loop where I perform the checks s ceratain amount of times

Thanks in advance.

Joe Fisher
  • 97
  • 1
  • 1
  • 6

0 Answers0