Replace a spinlock like wait with channel