RMI Callback and Threading

H

H. M?ller

Hello,

i build a thread pool that computes some kind of jobs. The jobs are
delivered by a RMI call (one call with jobarray) to the server
together with a reference to the client (RMI Callback). Each job was
computed by an own thread. A pool thread gets its jobs from a queue,
compute it and invokes a method on the client reference.

Sometimes i get a Connection refused Exception when i do the callback,
but other callbacks work well. So, i enclose the callback with a
synchronization block:

class PoolThread extends Thread {

public PoolThread(IClient client) {
this.client = client;
}

....
run() {
....
synchronized (client) {
client.returnJob(job);
}
....
}
....
}

Now it works, but i do not understand why. Can anybody give me a hint?
Is it because of several threads doing the callback concurrently? Does
the RMI framework not handle this case?

Again, everything worked well without the invokation of a callback
INSIDE a thead.

regards
Mr. Müller
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,989
Messages
2,570,207
Members
46,783
Latest member
RickeyDort

Latest Threads

Top