Archived
This forum has been archived. Please start a new discussion on GitHub.
Communicator ThreadSafe/proper use
glennleidy
in Help Center
I am using the java ice library.
I have found out ( rather painfully ) that the below statement
actually starts a background thread
Communicator communicator = Ice.Util.initialize();
and if one does not do
communicator.destroy()
a thread leakage problem occurs.
Currently I use a single communicator for each slice related thread I have
and I was not executing the destroy() method so when the thread ended I had
orphan "communicator" thread.
Can I use a single "communicator" for all threads in a JVM ( it is thread safe )
or should I make sure I am calling the destroy() method for each "communicator"
that I instantiate via Ice.Util.initialize() ?
Thanks,
Glenn
I have found out ( rather painfully ) that the below statement
actually starts a background thread
Communicator communicator = Ice.Util.initialize();
and if one does not do
communicator.destroy()
a thread leakage problem occurs.
Currently I use a single communicator for each slice related thread I have
and I was not executing the destroy() method so when the thread ended I had
orphan "communicator" thread.
Can I use a single "communicator" for all threads in a JVM ( it is thread safe )
or should I make sure I am calling the destroy() method for each "communicator"
that I instantiate via Ice.Util.initialize() ?
Thanks,
Glenn
0
Comments
-
Hi Glenn,
Calling destroy is indeed required to free resources allocated by the Ice communicator, for more information on this, see the Ice communicator documentation here.
It is fine to create a single communicator which is shared by multiple threads, this is the recommended way to use the communicator (an application should rarely need to create multiple communicators).
Cheers,
Benoit.0 -
Thank you. This is what I was hoping for.
Glennbenoit wrote: »Hi Glenn,
Calling destroy is indeed required to free resources allocated by the Ice communicator, for more information on this, see the Ice communicator documentation here.
It is fine to create a single communicator which is shared by multiple threads, this is the recommended way to use the communicator (an application should rarely need to create multiple communicators).
Cheers,
Benoit.0
