I am trying to implement a feature on a Stateless EJB so that when I try to access a resource and that resource doesn't respond at a given time, I want to interrupt the operation and get back to another processing (timeout).

Today I have this approach in J2SE using Threads but I know you cannot start Threads from within an EJB. Do you have any ideas on how to implement a timeout in this scenario? Could be something like:

J2EE Stateles EJB -- method call --> "Untrusted" Java API Call

What I'd like to do is to timeout this method call.

Any ideas?