我需要操作两个<代码>轮式工作。 其中一人只能在另一人完成后才能运作。 我能这样说吗?
class TestWorker {
private FirstWorker worker1;
private SecondWorker worker2;
public TestWorker() {
worker1 = new FirstWorker() {
@Override
protected void done() {
try {
result1 = get();
} catch (Exception) {
// exception handling
}
worker2 = new SecondWorker() {
@Override
protected void done() {
try {
result2 = get();
} catch (Exception) {
// exception handling
}
}
}
worker2.execute();
}
}
worker1.execute();
}
}
我如何取消这些限制? 与此类似:
private cancel() {
if (worker2 != null) work2.cancel();
if (worker1 != null) work1.cancel();
}
感谢很多!