Basic locking/synchronization helper functions and classes.