... continued

Ping Pong Example

We can rewrite our ping-pong example without busy waiting using Monitor. The two threads Wait() and Pulse() to not busy wait. The code is self-explanatory and appears below, the widget runs for ten seconds and then timees out.

Level up your interview prep. Join Educative to access 70+ hands-on prep courses.