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
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