Batch threads waiting for the monitor's attention.
Batch threads waiting for the monitor's attention.

Instead of doing waitpid() and processing one thread at a time, gather all waiting threads and then process them.

This avoids starving older threads when newer threads raise a lot of events.

PiperOrigin-RevId: 466366533
Change-Id: I81a878f038feac86407a8e961ecba181004f0f8a

google/sandboxed-api,google/sandboxed-api,google/sandboxed-api,google/sandboxed-api