如何在Spring @Async方法中获取任务?因为我想返回FutureTask,但是futureTask的构造方法需要传递Runnable或Callable参数。
之前
@Component
public class ConversionProcessor {
@Async
public Future<String> convert() {
//doing something
return new AsyncResult<>("Hello");
}
}
期望
@Component
public class ConversionProcessor {
@Async
public FutureTask convert() {
//doing something
return new FutureTask();
// compiler error, 'cannot resolve constructor FutureTask()'
}
}