Question

I am new to RMI world. I have one server and multiple clients. the server expose one and only one object in the main. this pretty object has a lot of methods (services to clients), and all of the clients use the same services (access the same services). I want to update my current project to use threads. I don't know what exactly what should be replaced by Runnable. I think that I might make the single object, which the server exposed, as Runnable. but I wonder how the client may interact with the object in this situation. please refer me to Any references you know to be familiar with this topic.

I don't want any code, but If there is a project that had faced the same problem you are engaged to share it with me. I need your ideas to design my solution. thanks in advance.

Was it helpful?

Solution

I want to update my current project to use threads.

Your project already uses threads. RMI is multithreaded. Two clients can and will execute methods on your remote object(s) simultaneously. It is up to you to prevent that in the appropriate places, by using synchronization or semaphores where you have non-thread-safe data structures for example.

I don't know what exactly what should be replaced by Runnable. I think that I might make the single object, which the server exposed, as Runnable. but I wonder how the client may interact with the object in this situation.

You don't need to implement Runnable or anything else. Multi-threading in RMI is already happening in your current code. What you need to pay attention to is not multi-threading, but thread safety of your code.

please refer me to Any references you know to be familiar with this topic.

See the RMI Specification, #3.2. The language used there sometimes confuses people, but what it means is that you cannot asssume RMI is single-threaded.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top