Solved

Interupting an RMI Method

Posted on 2006-06-28
5
229 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
[X]
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
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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

An old method to applying the Singleton pattern in your Java code is to check if a static instance, defined in the same class that needs to be instantiated once and only once, is null and then create a new instance; otherwise, the pre-existing insta…
In this post we will learn how to make Android Gesture Tutorial and give different functionality whenever a user Touch or Scroll android screen.
Viewers learn about the third conditional statement “else if” and use it in an example program. Then additional information about conditional statements is provided, covering the topic thoroughly. Viewers learn about the third conditional statement …
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:

730 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