Skip to main content

Garbage collector kills my thread and RMI server, please help !

2 replies [Last post]
shoom013
Offline
Joined: 2008-03-02
Points: 0

I have made a simple RMI/IIOP client/server application - in the RMI interface implementation I call a method in another class which extends Thread and creates an instance of itself and runs a thread leaving it: thread instance is started with run() and calling method returns to the query implementation which returns a String. I can see (with java -gc:verbose) RMI server and this thread working for while and then GC kills the thread and the whole RMI server ! Maybe I am doing it wrong - what I wanted to achieve is an asynchronous execution of a method in RMI server JVM. I am using OpenJDK 1.6 on Fedora, but similar thing happens on Sun JDK1.6 ... please, help !
ZP.

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
linuxhippy
Offline
Joined: 2004-01-07
Points: 0

Could you please post the GC log. I've never seen the GC to kill any threads.

shoom013
Offline
Joined: 2008-03-02
Points: 0

It does something like:

[GC 237754K->185533K(800384K), 0.0315230 sec]

after which I find my RMI server dead ... but, I have found a solution or a workaround - I was using http://java.sun.com/j2se/1.4.2/docs/guide/rmi-iiop/rmi_iiop_pg.html tutorial as the skeleton, and there I've put after creating the initial context and rebinding service a loop with Thread.sleep never to leave main of the server class - and it works ! Normally, this is not needed (if I don't user threads in the interface implementation), maybe I'm doing something wrong, but I can't tell.

Furthermore, for example about what I'm doing and in order to reproduce this, in SayHello method od HelloImpl class in the tutorial I am calling a method in another class which extends Thread, e.g. anotherClass.createThread() which creates a thread and starts it. It does something for a while (it is usually enough around 5-15 seconds to get it, but if it is loaded it will take much more) and then it gets killed together with RMI server (RMI server exits, which never happens otherwise).

ZP.