I just had to go through re-writing my singleton connection class to use ThreadLocal (quick and relatively painless, but a learning experience nonetheless)... Maybe someone else on the list has a better suggestion, but this seems to be the easiest way I've found of being able to use a pseudo-singleton pattern with ServiceClient. Like I said, with a lot of threads, you still end up with a lot of connections, but at least for me, sharing within the thread is a much bigger gain than worrying about sharing between threads.

-Will

Alexis Midon wrote:
well, actually I was trying to get ride of the threadLocal ;)
maybe I will stick with it.
Thanks for your answer!

nevertheless, can we get a rock-solid answer about this?

On Thu, May 22, 2008 at 4:35 PM, Will Briggs <[EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]>> wrote:

    Is it critical to share it amongst several threads, or are you
    just looking to minimize the number of clients you instantiate?
     Last I heard, ServiceClient was not thread-safe.  However, you
    can implement a Singleton pattern using ThreadLocal so that
    everything running within the same thread can share the service
    client.  This is pretty effective if you only have a few threads,
    but doesn't save you much if you have many.

    -Will


    Alexis Midon wrote:

        Hi all,

        I'd like to know if I can share one ServiceClient instance
        among several threads.

        Thanks,

        Alexis



    ---------------------------------------------------------------------
    To unsubscribe, e-mail: [EMAIL PROTECTED]
    <mailto:[EMAIL PROTECTED]>
    For additional commands, e-mail: [EMAIL PROTECTED]
    <mailto:[EMAIL PROTECTED]>



Reply via email to