Sets the boolean value in a thread-safe manner, entering and leaving the monitor.
the new boolean value.