Allow a Java method to work for a maximum of five seconds and want an exception to be thrown if the timeframe is exceeded. Here is how you can do it with jcabi-aspects and AspectJ - http://www.yegor256.com//2014/06/20/limit-method-execution-time.html