optimized synchronization to work without busy loops