Set running time limit on a method in java

后端 未结 4 738
一向
一向 2020-12-10 06:23

I have a method that returns a String, is it possible that after a certain time treshold is excedeed fot that method to return some specific string?

4条回答
  •  感情败类
    2020-12-10 07:03

    The Guava library has a very nice TimeLimiter that lets you do this on any method that's defined by an interface. It can generate a proxy for your object that has a "built-in" timeout.

提交回复
热议问题