RMI callback causes Swing GUI to freeze

D

Derek Smith

We have created a Swing based application which involves many clients
looking at, and changing, the same data.

Each time a client makes a change to data, we want this to be
reflected immediately in all the other clients.

To achieve this we have used the Observer design pattern - each client
registers itself with a server object via RMI.

When a client makes a change to a piece of data, it informs the server
object of the change. The server then informs all other clients via an
RMI callback.

This calls a method on the client which updates the Swing interface.

However, this often causes a client to freeze permanently.

We have read on the Sun Web site that a callback affecting a Swing
interface must run in the event-dispatching thread to avoid deadlock.
Therefore, our code on the client uses the SwingUtilities
..invokeLater() method (we have also tried invokeAndWait).

Unfortunately, clients still freeze regularly.

Can anyone help?
 
D

Dale Mitchell

We have created a Swing based application which involves many clients
looking at, and changing, the same data.

Each time a client makes a change to data, we want this to be
reflected immediately in all the other clients.

To achieve this we have used the Observer design pattern - each client
registers itself with a server object via RMI.

When a client makes a change to a piece of data, it informs the server
object of the change. The server then informs all other clients via an
RMI callback.

This calls a method on the client which updates the Swing interface.

However, this often causes a client to freeze permanently.

We have read on the Sun Web site that a callback affecting a Swing
interface must run in the event-dispatching thread to avoid deadlock.
Therefore, our code on the client uses the SwingUtilities
.invokeLater() method (we have also tried invokeAndWait).

Unfortunately, clients still freeze regularly.

Can anyone help?

Make sure that the client making the direct request to the server
doesn't have to wait until the server invokes all of the callbacks.
The server request should be made from a thread that isn't the event
dispatch thread. You can do this by creating a separate thread per
request on the client or implementing a non-blocking producer-consumer
queue on the server, or both. This will prevent one client from
freezing the others.

Dale
 

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

No members online now.

Forum statistics

Threads
473,766
Messages
2,569,569
Members
45,042
Latest member
icassiem

Latest Threads

Top