Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4012652
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T09:16:26+00:00 2026-05-20T09:16:26+00:00

I have been reading through the Java tutorial on RMI. I like the approach

  • 0

I have been reading through the Java tutorial on RMI. I like the approach that is outlined here for implementing a remote interface:

http://download.oracle.com/javase/tutorial/rmi/implementing.html

What I would like to know are 2 things:

1) With regard to the executeTask method outlined in the aforementioned link, how would this design allow Remote Objects (tasks) access some sort of global state if the ComputeEngine is just calling the execute method of a Task?

2) Would this design be suitable for a multi-threaded environment?

Thanks indeed.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T09:16:27+00:00Added an answer on May 20, 2026 at 9:16 am

    Ad. 1: Please note that remote client does not know anything about ComputeEngine class, only the Compute interface. Also, the server implementation might change completely, but if the interface does not change, client shouldn’t notice. If you want to pass some context to the task coming from remote client, do it on interface layer:

    public class ComputeEngine implements Compute {
    
    private GlobalContext globalContext = //...
    
    public <T> T executeTask(Task<T> t) {
        return t.execute(globalContext);
    }
    

    This way each task has access to the globalContext and knows exactly what to expect from globalContext (what are the server capabilities, the context). GlobalContext would be a JavaBean or more likely some service interface.

    On the client side it might look like this

    Compute compute = //obtain RMI client stub somehow
    compute.executeTask(new Task<String>() {
        public String execute(GlobalContext globalContext) {
            //Note that this code is executed on the server and
            //getFoo() is implemented on the server side. We only know its interface
            globalContext.getFoo();
            //...
        }
    }
    

    Ad. 2: It will work with multiple clients calling the service concurrently. However it is up to you to implement the server in thread-safe manner. The example from tutorial you mentioned in thread-safe, but my code using GlobalContext might not be. Please notice that several clients will use the same instance of globalContext concurrently, which might, but does not have to cause some issues. That’s probably the most interesting part.

    And finally remember that receiving unknown Task from remote client and running it on server is very impressive, but not quite safe.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been reading through this tutorial . I am in a chapter where
I have been reading through various questions on here, as I am learning VHDL
I have been reading through the C++ FAQ and was curious about the friend
I have been reading through the CodePlex supported open source licenses, i couldn't quite
I have been reading up on this, and it seems that if you use
I've been reading through a lot of the rookie Java questions on finalize() and
So, total newbie to Git. Been reading through the guides and think I have
I have been lately reading a lot on memory allocation schemes in java, and
I have been reading through the backlog of answered questions on SO regarding How
I recently bought Programming Scala , and have been reading through it. The language

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.