1秒后如何停止执行方法.时间? [英] How to stop excuting a method after say 1 sec. of time?
本文介绍了1秒后如何停止执行方法.时间?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在Java中有一个调用webservice的方法.现在,如果Web服务耗时超过1秒.时间.我应该可以终止该方法并继续执行程序流程.
I have a method in java which calls webservice. Now if the webservice is taking more than 1 sec. of time. I should be able to kill the method and continue in the program flow.
推荐答案
Google Guava's SimpleTimeLimiter will do what you need, specifically its callWithTimeout()
method.
这篇关于1秒后如何停止执行方法.时间?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文