java grpc spawns many new threads minecraft spigot plugin

hasNext() waits until an element arrives or the stream is closed.

If an element just hasn’t arrived yet, it will sit around waiting until another element arrives. When many calls do that, you get more threads waiting than elements, so threads keep stacking up.

So, more or less: you shouldn’t be structuring your receipt of the stream this way. Either use the async API and a StreamObserver — which seems to match your code’s needs anyway — or have run() consume the entire iterator, instead of trying to just consume one element.

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top