Fix for 3052 : IllegalMonitorStateException in replication HeartbeatThread
The replication HeartBeatThread uses non final Boolean for the synchronization
of the shutdown phase.
This can cause some rare IllegalMonitorStateException when trying to shutdown the HeartbeatThread because the Boolean can be modified by another thread.
The fix is to use a dedicated lock for this synchronization purpose.
This change also turn some replication objects that were used for sycnhronization
purpose into final objects so that the same bug cannot happen again.