Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/spring/11.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Spring @Async发生了什么。超时了吗?_Spring_Asynchronous_Spring 3 - Fatal编程技术网

Spring @Async发生了什么。超时了吗?

Spring @Async发生了什么。超时了吗?,spring,asynchronous,spring-3,Spring,Asynchronous,Spring 3,假设我有一个挂起的@Async方法调用。会暂停吗?这里什么是释放资源的最佳实践 @Async方法调用在指定的线程池中执行。如果您的方法挂起,它将无限地保存池中的一个线程。春天对此无能为力 如果您的方法很好地接受了InterruptedException,您可以通过调用异步方法返回的值来取消它。您能给我一些关于这方面的详细信息吗。未来的回报值是多少?然后我如何知道是否发生了异常?请仔细阅读的JavaDocs,Future.get()会在从任务中抛出异常时抛出异常。谢谢。你解决了它。get(time

假设我有一个挂起的
@Async
方法调用。会暂停吗?这里什么是释放资源的最佳实践

@Async
方法调用在指定的线程池中执行。如果您的方法挂起,它将无限地保存池中的一个线程。春天对此无能为力


如果您的方法很好地接受了InterruptedException,您可以通过调用异步方法返回的值来取消它。

您能给我一些关于这方面的详细信息吗。未来的回报值是多少?然后我如何知道是否发生了异常?请仔细阅读的JavaDocs,
Future.get()
会在从任务中抛出异常时抛出异常。谢谢。你解决了它。get(time,TimeUnit)引发异常。在catch或finally中,我们可以调用cancel。@user874774:不,您误解了什么。当
get()
返回或抛出时,任务已完成。调用
cancel()
没有多大意义。