On Thu, Aug 23, 2018 at 3:00 PM <eleanore....@gmail.com> wrote:

> my grpc client and server are doing bi-directional streaming, in the
> StreamObserver.onNext() the client passed to server, its just print out the
> response from the server.
> And on the client side, when creating the channel, I passed a
> fixedThreadPool with 5 threads. And I see from client side, the results get
> printed by 5 threads.  So that means 5 threads are accessing the same
> StreamObserver object, but as you mentioned StreamObserver is not thread
> safe?
>
> Since the onNext() is just System.out.println(), maybe the threads do not
> access the StreamObserver concurrently. but what if the logic of process
> the response takes time, and when thread1 hasn't finished with its onNext()
> call, the next response arrives, and another thread trying to process it,
> is there any consequence of this scenario?
>

We make sure to call it only from one thread at a time. We'll continue
re-using a thread for delivering callbacks if more work is coming. But if
there's a period of no callbacks we'll return from the thread. The next
time we need to do callbacks a different thread may be chosen.

-- 
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 grpc-io+unsubscr...@googlegroups.com.
To post to this group, send email to grpc-io@googlegroups.com.
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/CA%2B4M1oOT3n6ne0V%3DrVus%2BY_GnDsQdz-jOaFGBki0EA9nWu7NoQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Attachment: smime.p7s
Description: S/MIME Cryptographic Signature

Reply via email to