Implementing a synchronization primative