Thanks for your help.
I found a class that ensures synchronization of StreamObserver methods.
Link: https://github.com/stargate/stargate
public class SynchronizedStreamObserver implements StreamObserver {
private final StreamObserver streamObserver;
public
Yes, you should not have two threads calling onNext() on the same
StreamObserver. If you do, you can get messages interleaved with each other
and most likely just produce garbage.
You need to make sure that your application acquires a lock before calling
any of the methods on StreamObserver.