INT-2880 fix System.out concurrent race condition

Gradle may run tests via multi-threaded way.
Using shared resources (e.g. `System.out`) may produce concurrency issues.

* Add first `synchronized (System.out)` to ensure that current Thread waits lock on resource
* Add second `synchronized (System.out)` to ensure that current Thread takes lock from other Threads on replaced resource

JIRA: https://jira.springsource.org/browse/INT-2880