use of org.apache.pivot.util.concurrent.TaskSequence in project pivot by apache.
the class TaskTest method testTaskSequence.
@Test
public void testTaskSequence() {
TaskListener<Void> taskListener = new TaskListener<Void>() {
@Override
public synchronized void taskExecuted(Task<Void> task) {
System.out.println("EXECUTED");
notify();
}
@Override
public synchronized void executeFailed(Task<Void> task) {
System.out.println("FAILED: " + task.getFault());
notify();
}
};
TaskSequence taskSequence = new TaskSequence();
SleepTask task1 = new SleepTask(500);
taskSequence.add(task1);
SleepTask task2 = new SleepTask(1000);
taskSequence.add(task2);
SleepTask task3 = new SleepTask(2000);
taskSequence.add(task3);
synchronized (taskListener) {
taskSequence.execute(taskListener);
try {
taskListener.wait();
} catch (InterruptedException exception) {
// empty block
}
}
}
Aggregations