use of org.apache.pivot.util.concurrent.TaskGroup in project pivot by apache.
the class TaskTest method testTaskGroup.
@Test
public void testTaskGroup() {
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();
}
};
TaskGroup taskGroup = new TaskGroup();
SleepTask task1 = new SleepTask(500);
taskGroup.add(task1);
SleepTask task2 = new SleepTask(1000);
taskGroup.add(task2);
SleepTask task3 = new SleepTask(2000);
taskGroup.add(task3);
synchronized (taskListener) {
taskGroup.execute(taskListener);
try {
taskListener.wait();
} catch (InterruptedException exception) {
// empty block
}
}
}
Aggregations