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

  • SEARCH
  • Home
  • 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 8319519
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T22:21:07+00:00 2026-06-08T22:21:07+00:00

I have some difficulties to understand which thread execute particular method. Are there any

  • 0

I have some difficulties to understand which thread execute particular method. Are there any methods on server side? I am new to RMI.

HelloClient:

public class HelloClient 
{
    Random rand = new Random();

    public static void main(String[] args) 
    {
        Thread.currentThread().setName("Thread of a client");
        if(System.getSecurityManager() == null) 
        {
            System.setSecurityManager(new RMISecurityManager());
        }

        HelloClient hc = new HelloClient();
        hc.methodToMeasureEnglish();
    } 


    void methodToMeasureEnglish()
    {
        try
        {
            Thread.sleep(Math.abs(rand.nextInt()%4000));
            Registry reg = LocateRegistry.getRegistry("localhost", 6666);
            HelloIF hello = (HelloIF) reg.lookup("HELLO"); 
            System.out.println(hello.sayHelloEnglish());
        }
        catch( Exception e ) 
        {
            e.printStackTrace();
        }
    }
}

Hello:

public class Hello extends UnicastRemoteObject implements HelloIF 
{
    public Hello(String name) throws RemoteException
    {
        try 
        {
            Registry registry = LocateRegistry.createRegistry(6666);
            registry.rebind(name, this);
        }
        catch(Exception e) 
        {
            e.printStackTrace();
        }
    }


    public String sayHelloEnglish() 
    {
        return "GOOD MORNING";
    }
}

HelloIF

public interface HelloIF extends Remote 
{
    public String sayHelloEnglish() throws RemoteException;
}

HelloServer

public class HelloServer 
{ 
        public static void main(String[] args) throws Exception 
        {
            Thread.currentThread().setName("Server Thread");
            if(System.getSecurityManager() == null) 
            { 
                System.setSecurityManager(new RMISecurityManager()); 
            }
            Hello myObject = new Hello("HELLO");
            System.out.println( "Server is ready..." );
        }

}

Am I using RMI right?

I added AspectJ class

@Aspect
public class MeasureAspect 
{  
    private static Logger logger = Logger.getLogger(MeasureAspect.class);

    @Around("call(void method*())")  
    public Object condition2(ProceedingJoinPoint joinPoint) throws Throwable 
    {   
        PropertyConfigurator.configure("log4j.properties");
        Object res = joinPoint.proceed();
        logger.info("Thread method " + Thread.currentThread().getName());     
        return res;
    }  

    @Around("call(String say*())")  
    public Object condition1(ProceedingJoinPoint joinPoint) throws Throwable 
    {   
        PropertyConfigurator.configure("log4j.properties");
        Object res = joinPoint.proceed();
        logger.info("Thread say " + Thread.currentThread().getName());   
        return res;
    }  

}

All logs come from Client Thread. Could you explain me witch threads execute my methods?

  • 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-06-08T22:21:10+00:00Added an answer on June 8, 2026 at 10:21 pm

    The RMI Specification says you cannot make any assumptions about which thread remote methods execute on. Specifically this implies several things:

    1. You can’t assume it is single threaded.
    2. You can’t assume that successive calls from the same client thread will execute in the same server thread.
    3. You can’t assume it will all execute in the main thread, not that that makes any sense.

    In practice, subject to thread pooling if any at the server (Oracle JVMs don’t do that but I believe IBM’s does), and/or collection pooling at the client (Oracle JVMs do that, don’t know about IBM), each method invocation is executed on its own thread.

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

Sidebar

Related Questions

I'm have some difficulties here, I am unable to successfully call a method which
I have some difficulties for using Ruby block, passing in a method. As in
I am new to programing and I have some difficulties getting AlertDialog working. I
I have some difficulties in finding the directory in which a given class lies.
I am pretty new to Wicket and i have some difficulties with using resource
I have some difficulties understanding how the access method Do not move cursor automatically
I am new to Haskell and have some difficulties wrapping my head around some
I have some difficulties with the mod_rewrite rules. I want to rewrite any request
I am new to WCF and I have some difficulties understanding certain things... I
I have some difficulties to set up the correct configuration relative to sendAsynchronousRequest:queue:completionHandler: method

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.