Better threads synchronization