Proper way to set timeout on a method in Java
<p>I've looked over some existing answers here on SO and I've used <a href="http://docs.oracle.com/javase/1.5.0/docs/api/java/util/concurrent/Future.html" rel="nofollow">Future</a> in combination with <a href="http://docs.oracle.com/javase/6/docs/api/java/util/concurrent/ExecutorService.html" rel="nofollow">ExecutorService</a> to set timeout with <a href="http://docs.oracle.com/javase/6/docs/api/java/util/concurrent/TimeUnit.html" rel="nofollow">TimeUnit</a> to method.</p>

<p>But I'm trying to set timeout on a method inside my service implementation meaning that caller class is consuming interface.</p>

<p>So I'd like to avoid implementing callable in my service implementation, because I want this method to get executed in the same Thread.</p>

<p>Is there other way to set timeout or simulate timeout on a given method ?</p>
