• Post Reply Bookmark Topic Watch Topic
  • New Topic

Interrupt an executing method  RSS feed

 
Lin Shen
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, I have an object obj, which can be called by other threads to execute a service method, obj.service(). does anybody know how can I abort the execution? So other processes can call obj.service() ?
 
Edward Harned
Ranch Hand
Posts: 291
Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Peter Curila
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Call interrupt method.
 
Lin Shen
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry, I didnt described it clearly in the last post. What I actually want is to interrupt any other programs that called by Runtime exec method.

This program might run in an infinite loop. So How can I interrupt it from the Java main thread.

Thanks
 
Paul Clapham
Sheriff
Posts: 22379
42
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't know how you can "interrupt" that process, if that means you want it to pause and then continue later. If you want to destroy (kill) the process then all you do is this:
 
Lin Shen
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thats exactly what I want. I will try that. Thanks
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!