Hi Eric, 

Thanks a lot for the explanation. If I understand you correctly, at certain 
point in time, there will only be 1 thread processing the callback, and 
there will NEVER be multiple threads processing the callbacks concurrently. 
If this is the case, what is the point of having the executor() 
configuration in ChannelBuilder and ServerBuilder? 

Thanks a lot!

On Friday, August 24, 2018 at 7:17:22 AM UTC-7, Eric Anderson wrote:
>
> On Thu, Aug 23, 2018 at 3:00 PM <[email protected] <javascript:>> 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 [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/1acaf215-f36d-4eaa-9ebb-bbed32034126%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to