I am creating a JAVA application that use Bonita BPM API, i am using a simple code like this:
ProcessInstance processInstance = App.getProcessAPI().startProcess(App.getProcessDefinitionId(),App.getListOperation(), listVariablesSerializable);
processId = processInstance.getId();
Thread.sleep(1000);
App.getBuilder().filter(ProcessInstanceSearchDescriptor.STARTED_BY, App.getAPISession().getUserId());
App.setPendingTasks(0, 30, null);
This code start a new process and set the new tasks to the user. But only works with Thread.sleep(1000)
because App.setPendingTasks(0, 30, null)
doesn't want to wait for App.getProcessAPI().startProcess(App.getProcessDefinitionId(),App.getListOperation(), listVariablesSerializable);
to end.
I know that Thread.sleep(1000)
is not a good programming practice and I need another solution please.