Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Interupting an RMI Method

Posted on 2006-06-28
5
228 Views
Last Modified: 2010-03-31
Hi,

I would just like to know if it is possible to interupt an RMI method.

Suppose ane Application call it 'A' had to invoke an RMI method in an object hosted by another application say 'B' and the RMI method hosted by B had some code to the effect of "while(true)" or "for(;;;)".

Would it be possible for application A to interupt the RMI method or would the thread in A that invoked the method be blocked forever until application B terminated.

Thanks in advance for any suggestions.

0
Comment
Question by:mric5180
5 Comments
 
LVL 23

Expert Comment

by:Ajay-Singh
ID: 17007034
Try interrupting the thread that running RMI call.
0
 
LVL 35

Expert Comment

by:girionis
ID: 17007370
> would the thread in A that invoked the method be blocked forever until application B terminated.

It depends on where it is running. If application A is runnign on the main thread then it will be block and you won't have any chance to interrupt it. If it is running from *another* thread then you could add your own code to handle such functionallity.
0
 
LVL 8

Expert Comment

by:colr__
ID: 17007587
If A calles a method in B, then A shouldnt be able to continue until it has a satisfactory response from B (or at least, B returns). In the case where it is interrupted, that may not be the case and so your program could lose stability.

Does B return anything? Could it be run in a thread so that A simply calles the mehtod then continues with its own exectution?

colr__
0
 

Author Comment

by:mric5180
ID: 17014184
In response to colr's comment:

I'm not in control of both sides of the interface, another company is coding Application B, the one whichs hosts the RMI method so i have no control over what that method does.

What i am trying to do is mitigate the risk that the RMI method never returns. I already invoke the method in B from a seperate thread in Application A so as to allow the rest of the application to continue however should the method in B never return i'm stuck with a thread i don't want.

So what i really want to be able to do is interupt an RMI call if it is taking too long.
0
 
LVL 35

Accepted Solution

by:
girionis earned 400 total points
ID: 17015891
You can make the thread exit or timeout after a specific amount of time, if method B never returns. Provide a method in your thread class that other objects can use it to ask it to stop running.
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be u…
Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.

828 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question