The stub and channel are thread safe meaning many threads can use these objects to begin RPCs safely.
For streaming RPCs, you'll have to pass in a StreamObserver and get back a StreamObserver. They are not thread safe because they contain unsynchronized code and data. For example, there is a flag that is set true if "cancel" is called, and will throw an error if you ever send a message after calling "cancel". As long as the StreamObservers do not interact across threads you are fine. If you do, you must add synchronization at the application level. On Sunday, November 12, 2017 at 7:38:21 PM UTC-8, Rama Rao wrote: > > All, > If service uses Streaming calls (client, server or both) - can we create > single stub (and channel) and reuse it across multiple calls that happen in > multiple threads? Java doc says "StreamObserver" is not thread safe. But > just want to confirm what scenarios are not thread safe? > > Thanks, > Rama > -- You received this message because you are subscribed to the Google Groups "grpc.io" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at https://groups.google.com/group/grpc-io. To view this discussion on the web visit https://groups.google.com/d/msgid/grpc-io/e52153d2-cf23-4704-b9d1-c9f26476dae0%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
