Im struggling to get this done. I have an User Interface in Java that controls a system using JPL, prolog.
Firstly i run a simple query assert(goal( work_1 )). When the process is done it just asserts done( work_1 ). To process the next goal goal( do(work_2 ) I must wait for the fact  done( work_1 ).
for (String s : t) {
    runQuery("assert(goal(" + s + "))"); //start process
    //
    // Here the User Interface should block until done(A) and A == s
    //
    while (!active) {
        Map<String, Term>[] Q = Query.allSolutions("done(Goal)");
        for (Map<String, Term> sol : Q) {
            String str = "" + sol.get("Goal");
            if (str.equals(s)) {
                active = false;
        }
    }
    runQuery("retract(done(_))");
}
How can i make this work correctly?