Implementing correct implementation using monitors.