I do this in RMI. See Tymeac product documentation:
http://coopsoft.com/TyDoc/Cancel.html It involves using multiple threads and is harder than it looks.
Thread A calls thread B and waits for a reply. Thread B calls service(). If thread B never returns, you can use thread C to notify() thread A that the request is cancelled.
That's basiclly how it works. The implementation is a little more complex.