synchronization for publisher and subscriber