using locking macro to mimic synchronized method behavior