updated lock routines with c++ style casting