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 7532205
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T05:23:01+00:00 2026-05-30T05:23:01+00:00

To make a long story short, I’m having trouble getting a couple of Java

  • 0

To make a long story short, I’m having trouble getting a couple of Java RMI’s non-daemon threads to close out after my application no longer needs RMI. This prevents the JVM from exiting when main() completes.

I understand that exporting UnicastRemoteObjects will cause RMI to leave threads open until you successfully call UnicastRemoteObject.unexportObject(Object o,boolean force). Here’s an example (run without modification and the JVM will exit normally – remove the call to unexportObject and the JVM will never exit):

import java.rmi.registry.LocateRegistry;
import java.rmi.registry.Registry;
import java.rmi.server.UnicastRemoteObject;

public class TestUnicastRemoteObject{
private static UnicastRemoteObject obj;
private static Registry registry;

public static void main(String[] args) throws Exception{
    obj = new UnicastRemoteObject(){
        private static final long serialVersionUID = 1L;
    };
    System.err.println("created UnicastRemoteObject");
    System.err.println("creating registry ...");
    registry = LocateRegistry.createRegistry(9999);
    System.err.println("registry created.");
    System.err.println("binding obj to registry ...");
    registry.bind("Test", obj);
    System.err.println("bound");
    UnicastRemoteObject.unexportObject(obj, true);
    System.err.println("unexported obj");
}
}

Also, it doesn’t seem to matter whether you create the registry and/or bind the remote object to it – the only thing that seems to matter in this example is that any time you create a UnicastRemoteObject, you need to call unexportObject in order to prevent any threads from remaining after you’re done.

In my application, I’ve made sure that I’ve called unexportObject on every UnicastRemoteObject I create, and yet RMI’s “reaper” thread and “connection accept” thread still persist, preventing my JVM from exiting when my application is finished using RMI resources.

Is there something else that could cause RMI to leave threads behind, aside from forgetting to unexport UnicastRemoteObjects?

  • 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-30T05:23:02+00:00Added an answer on May 30, 2026 at 5:23 am

    Sure enough, I had a bug in the code that caused one of my (many) UnicastRemoteObjects to not unexport itself when the calling application was done utilizing it. So the answer is:

    Unexporting all UnicastRemoteObjects within a running JVM is sufficient to close all RMI non-daemon threads.

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

Sidebar

Related Questions

So to make a long story short. A professor asked this question in class
Short story: I can't make precompiled headers work properly with gcc -c option. Long
To make a long story short, I'm trying to pass a list of dictionaries
Okay so to make a long story short I am using this script in
I'm going to make a long story short. It's been a while that I
It's hard to describe the whole problem but to make a long story short,
To make a long story short I have to use processing in a class
I'll try to make a long story short: I want to call a method
To make a long story short, my terminal was not working so a forum
To make a long story short, it looks as if I am going to

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.