Archived

This forum has been archived. Please start a new discussion on GitHub.

Using checkedCast for multiple instances of the "same" proxy

My client has multiple threads, each of which need to access a (stateless) server. My first (naiive?) attempt is to create one proxy before starting the worker threads and letting them share this. I have a feeling that this may not be a good idea; that maybe access to this proxy will be serialized.

The next attempt would be to create a separate proxy for each worker thread which, if I used checkedCast, would incur a call to the server for each proxy but this initially seems wasteful.

What would be best practice in a case like this?

/Kim

Comments

  • marc
    marc Florida
    A single proxy is all you need. Requests are not serialized. They are dispatched on the server in parallel, provided that you have configured the server-side thread pool with more than one thread.

    Instead of checkedCast(), you can use unchceckedCast(), provided that you know that the proxy is indeed of the correct type. As the names imply, checkedCast() will check with the server whether the type matches, while uncheckedCast() is a purely local operation.