0

I am working on java fxml where i take 2 inputs and use them to run a script. I pause at execution points of the script

My problem is when i provide only 1 input (ex 1 2 add 3 equal)the code runs fine but when I am providing 2 inputs (ex 1 2 add and 3 equal) the code stops at countDownLatch.await() at the very last step and does not print the script output.

I am starting on fxml button click something like below

Executors.newSingleThreadExecutor().submit(()-> {
method(ui_inputs1);
method(ui_inputs2)
}):

I am trying to achieve pause in FXML UI ie until the user clicks next something like debug where a user will select UI points to pause at.

so something like this

public void onExcecute(
if (debugMode) {

//check is breakpoint the do Platform.runLater(() + UI updates//
countDownLatch.await();
countDownLatch = new CountDownLatch(1);

}
}

when user click Play next button it moves to next step till it hits execution point

   public void onHitBreakpoint() {
    Platform.runLater(()->{
        addStackDebug(listener,false);});
}

 playToNextExecPoint() {
 countDownLatch.countDown();
 }

 public void onfinish{
// script success or failed
}

Console log for the correct execution is:

Lets parse 1 2 ADD 3 EQUAL

Executing OP_CODE operation: [1]

Lets parse 1 2 ADD 3 EQUAL

-------Press 'Play' To Continue--------

Executing OP_CODE operation: [2]

Lets parse 2 ADD 3 EQUAL

-------Press 'Play' To Continue--------

Executing OP_CODE operation: [ADD]

Lets parse ADD 3 EQUAL

-------Press 'Play' To Continue--------

Executing OP_CODE operation: [3]

Lets parse 3 EQUAL

-------Press 'Play' To Continue--------

Executing OP_CODE operation: [EQUAL]

Lets parse EQUAL -------Press 'Play' To Continue-------- Script success. Script success.

When I provide 2 inputs, the prints in Bold and Italics are missing

nehamansha
  • 11
  • 3
  • 1
    The simplest way is to use the [`ExecutorService.awaitTermination`](https://docs.oracle.com/javase/8/docs/api/java/util/concurrent/ExecutorService.html#awaitTermination-long-java.util.concurrent.TimeUnit-) method. – Andy Turner Apr 10 '19 at 13:28
  • I think your question would be clearer if you provided a [mcve]. – Slaw Apr 10 '19 at 13:34
  • The console log is the output. I can try and clear it up – nehamansha Apr 10 '19 at 13:36
  • @AndyTurner will try thanks – nehamansha Apr 10 '19 at 13:36
  • "_The console log is the output. I can try and clear it up_". Not sure if that was directed at my comment, but the issue isn't the console output. The problem, for me at least, is it's difficult to understand the flow of your program with so little code. You're having problems waiting for one or more tasks to complete, but the issue could be caused by something you aren't showing us—hence the request for a [mcve]. – Slaw Apr 10 '19 at 13:39
  • @Slaw Sorry. the code in Execution service is a 3rd party code. If dont have a debug mode on the code runs fine, hence I thought its the countDownLatch issue. I adding some more code – nehamansha Apr 10 '19 at 13:54

0 Answers0